Solved

How to set Mouse pointer to hourglass

Posted on 2001-09-06
50
561 Views
Last Modified: 2007-12-19
Hi experts,
When I upload file to server,it take several seconds to process.how can I set the Mouse pointer to Hourglass during this time? or is there a way to disable the Upload button during this time.
Tanks
Suying
0
Comment
Question by:suying
  • 25
  • 14
  • 7
  • +1
50 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 6461764
Using the Style Sheet property, cursor:wait
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6461775
So I guess you could call the style property when onClick="" is called...
0
 

Author Comment

by:suying
ID: 6461785
mqfranz,
thanks for the input. could you tell me how to use Style Sheet property and put it where.
here is the code to upload file
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
     <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
     <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
     <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
     </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>

Could you please give me some code.
Thanks
suying
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6461812
It was just a suggestion... no code...

Where is Sub done getting called?
0
 

Author Comment

by:suying
ID: 6461821
from:
<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>
suying
0
 

Author Comment

by:suying
ID: 6461833
Hi mqfranz,
the <INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>
is used to close this window and back to another window. the
<INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
is used to upload file.

any suggestion?
Thanks
Suying
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6461838
Now that I think about it, using the Style property will not work... since style properties are set on page load, the only way to change the style would be to reload the page, sorry.
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6464740
Actually, since you are using vbscript, assume this is an ie based application.  If so, you can change styles dynamically.

Here is a change to your vbscript code, try it and see if it works, orplace this where it will be called during the upload.  

<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
document.body.style.cursor = "wait"
end sub
-->
</script>


Then you will need to add something somewhere that processes when the upload is complete to turn it off.

davlun
0
 

Author Comment

by:suying
ID: 6465027
Davlun,
Thanks for the input. the Done button is for close current(upload file window)window and go back to getautonum.asp. so I can't put the document.body.style.cursor="wait". maybe I can add  sub Upload_Onclick and add document.body.style.cursor="wait" in this sub,Could you please tell me how:>>Then you will need to add something somewhere that processes when the upload is complete to turn it off.(because I don't know how. thanks)
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6465048
Some of what you ask i can not do because i do not know how your site is put together as a whole.

As for the first part of your response, you already have the pieces in your response.  Try creating a sub Upload_Onclick and placing the line, document.body.style.cursor = "wait" in the sub.  Try it ans see if it works.

If so, give me more info about how your server handles the upload so you know when the upload is complete.  Once you know when the upload is complete, we can write something to change the cursor back.

davlun
0
 

Author Comment

by:suying
ID: 6465467
Hi davlun,
thanks.I've added the code as you told me:
Sub Upload_Onclick()
document.body.style.cursor = "wait"
end sub
it doesn't work because I didn't see any change as before.
here is the code in uploadform.htm
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
      <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
      <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
      <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
      </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>
and here is the code in uploadfile.asp
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security Info=True"
objcon.ConnectionString=constring
 objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
      Response.Write "File(s) not uploaded."
Else
      ' Loop through the uploaded files
      For Each File In Uploader.Files.Items
                              
                  ' Open the table you are saving the file to
       Set RS = Server.CreateObject("ADODB.Recordset")
         RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
             RS.AddNew ' create a new record
             RS("AttachID")=1
             RS("ARNumber")=Session("arnumber")
             RS("FileName")    = File.FileName
             RS("FileSize")=File.FileSize
             RS("ContentType")=File.ContentType
                  ' Save the file to the database
             File.SaveToDatabase RS("Attachment")
            
                  ' Commit the changes and close
             RS.Update
             RS.Close
            
            
      Next
End If
Response.Redirect "uploadform.htm"
%>
the code for upload.asp(which is a include file in uploadfile.asp)is:
<%

Class FileUploader
      Public  Files
      Private mcolFormElem

      Private Sub Class_Initialize()
            Set Files = Server.CreateObject("Scripting.Dictionary")
            Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(Files) Then
                  Files.RemoveAll()
                  Set Files = Nothing
            End If
            If IsObject(mcolFormElem) Then
                  mcolFormElem.RemoveAll()
                  Set mcolFormElem = Nothing
            End If
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
      End Property

      Public Default Sub Upload()
            Dim biData, sInputName
            Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
            Dim nPosFile, nPosBound
            biData = Request.BinaryRead(Request.TotalBytes)
            nPosBegin = 1
            nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
            
            If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
             
            vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
            nDataBoundPos = InstrB(1, biData, vDataBounds)
            
            Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
                  
                  nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
                  nPos = InstrB(nPos, biData, CByteString("name="))
                  nPosBegin = nPos + 6
                  nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
                  sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
                  nPosBound = InstrB(nPosEnd, biData, vDataBounds)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile, sFileName
                        Set oUploadFile = New UploadedFile
                        
                        nPosBegin = nPosFile + 10
                        nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
                        sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
                        nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
                        nPosBegin = nPos + 14
                        nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                        
                        oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        
                        nPosBegin = nPosEnd+4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                        
                        If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
                  Else
                        nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                        nPosBegin = nPos + 4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  End If

                  nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
            Loop
      End Sub

      'String to byte string conversion
      Private Function CByteString(sString)
            Dim nIndex
            For nIndex = 1 to Len(sString)
               CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function CWideString(bsString)
            Dim nIndex
            CWideString =""
            For nIndex = 1 to LenB(bsString)
               CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public FileName
      Public FileData
      
      Public Property Get FileSize()
            FileSize = LenB(FileData)
      End Property

      Public Sub SaveToDisk(sPath)
            Dim oFS, oFile
            Dim nIndex
      
            If sPath = "" Or FileName = "" Then Exit Sub
            If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
      
            Set oFS = Server.CreateObject("Scripting.FileSystemObject")
            If Not oFS.FolderExists(sPath) Then Exit Sub
            
            Set oFile = oFS.CreateTextFile(sPath & FileName, True)
            
            For nIndex = 1 to LenB(FileData)
                oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
            Next

            oFile.Close
      End Sub
      
      Public Sub SaveToDatabase(ByRef oField)
            If LenB(FileData) = 0 Then Exit Sub
            
            If IsObject(oField) Then
                  oField.AppendChunk FileData
            End If
      End Sub

End Class
%>
( I will increase the points since you spend lot of time on my question)
Thanks
Suying
0
 

Author Comment

by:suying
ID: 6465503
Hi davlun,
thanks.I've added the code as you told me:
Sub Upload_Onclick()
document.body.style.cursor = "wait"
end sub
it doesn't work because I didn't see any change as before.
here is the code in uploadform.htm
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
      <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
      <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
      <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
      </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>
and here is the code in uploadfile.asp
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security Info=True"
objcon.ConnectionString=constring
 objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
      Response.Write "File(s) not uploaded."
Else
      ' Loop through the uploaded files
      For Each File In Uploader.Files.Items
                              
                  ' Open the table you are saving the file to
       Set RS = Server.CreateObject("ADODB.Recordset")
         RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
             RS.AddNew ' create a new record
             RS("AttachID")=1
             RS("ARNumber")=Session("arnumber")
             RS("FileName")    = File.FileName
             RS("FileSize")=File.FileSize
             RS("ContentType")=File.ContentType
                  ' Save the file to the database
             File.SaveToDatabase RS("Attachment")
            
                  ' Commit the changes and close
             RS.Update
             RS.Close
            
            
      Next
End If
Response.Redirect "uploadform.htm"
%>
the code for upload.asp(which is a include file in uploadfile.asp)is:
<%

Class FileUploader
      Public  Files
      Private mcolFormElem

      Private Sub Class_Initialize()
            Set Files = Server.CreateObject("Scripting.Dictionary")
            Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(Files) Then
                  Files.RemoveAll()
                  Set Files = Nothing
            End If
            If IsObject(mcolFormElem) Then
                  mcolFormElem.RemoveAll()
                  Set mcolFormElem = Nothing
            End If
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
      End Property

      Public Default Sub Upload()
            Dim biData, sInputName
            Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
            Dim nPosFile, nPosBound
            biData = Request.BinaryRead(Request.TotalBytes)
            nPosBegin = 1
            nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
            
            If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
             
            vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
            nDataBoundPos = InstrB(1, biData, vDataBounds)
            
            Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
                  
                  nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
                  nPos = InstrB(nPos, biData, CByteString("name="))
                  nPosBegin = nPos + 6
                  nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
                  sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
                  nPosBound = InstrB(nPosEnd, biData, vDataBounds)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile, sFileName
                        Set oUploadFile = New UploadedFile
                        
                        nPosBegin = nPosFile + 10
                        nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
                        sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
                        nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
                        nPosBegin = nPos + 14
                        nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                        
                        oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        
                        nPosBegin = nPosEnd+4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                        
                        If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
                  Else
                        nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                        nPosBegin = nPos + 4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  End If

                  nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
            Loop
      End Sub

      'String to byte string conversion
      Private Function CByteString(sString)
            Dim nIndex
            For nIndex = 1 to Len(sString)
               CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function CWideString(bsString)
            Dim nIndex
            CWideString =""
            For nIndex = 1 to LenB(bsString)
               CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public FileName
      Public FileData
      
      Public Property Get FileSize()
            FileSize = LenB(FileData)
      End Property

      Public Sub SaveToDisk(sPath)
            Dim oFS, oFile
            Dim nIndex
      
            If sPath = "" Or FileName = "" Then Exit Sub
            If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
      
            Set oFS = Server.CreateObject("Scripting.FileSystemObject")
            If Not oFS.FolderExists(sPath) Then Exit Sub
            
            Set oFile = oFS.CreateTextFile(sPath & FileName, True)
            
            For nIndex = 1 to LenB(FileData)
                oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
            Next

            oFile.Close
      End Sub
      
      Public Sub SaveToDatabase(ByRef oField)
            If LenB(FileData) = 0 Then Exit Sub
            
            If IsObject(oField) Then
                  oField.AppendChunk FileData
            End If
      End Sub

End Class
%>
( I will increase the points since you spend lot of time on my question)
Thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6465553
hmmm, so you want the cursor to go to an hourglass after you click the submit button in uploadform.htm?
0
 

Author Comment

by:suying
ID: 6465639
Davlun,
Yes.that's what I'm want.is that possible? if yes,could you please tell me how?

thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6465644
Add the following code to the top of uploadform.asp, insert it right before you create the file uploader.

response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .</body></html>

If this works, it will write out a blank page while the stuff is processing and the cursor should be an hourglass as well, not sure on this one but we will see soon enough

davlun
0
 

Author Comment

by:suying
ID: 6465696
Hi Davlun,
when I add the code you gave me, I got the follow output:
Please Wait...
Response object error 'ASP 0156: 80004005'
Header Error
AROnline/uploadfile.asp line 50
The HTTP line already written to the client browser,Any HTTP header modification must be made before writing page content.
(because I have a response.redirect "uploadform.htm" in uploadfile.asp used to let people upload more file)

the mouse pointer is hourglass.

Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6465730
Ok, did not think that would matter....

So change the first line i gave you to:
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please
Wait . . "

and where you have the redirect, add this instead of the redirect:
response.write "<script language=""javascript"">window.location.replace(""uploadform.htm"")</script></body></html>"

basically I am using javascript to redirect back when the asp page is finished.  I am using the replace method to keep the processing page from being added to the history.

if this doesn't work I am out of easy solutions,
davlun

0
 

Author Comment

by:suying
ID: 6465766
Hi Davlun,
if I change the code to what you gave me,it didn't show Please Wait... and the mouse pointer didn't change to hourglass.
Suying
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6467981
all the code have to be in the same page to make it work.
try this:

response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please
Wait . . .</body></html>
response.Flash

do upload work...

response.redirect "OtherPage.asp"


0
 

Author Comment

by:suying
ID: 6468783
Thanks Eyal,I will check the code on Monday.
Suying
0
 

Author Comment

by:suying
ID: 6471061
Hi Eyal,
when I add the code in uploadfile.asp(if I'm right)I got the follow page:
when I add the code you gave me, I got the follow output:
Please Wait...
Response object error 'ASP 0156: 80004005'
Header Error

AROnline/uploadfile.asp line 50
The HTTP line already written to the client browser,Any HTTP header modification must be made before
writing page content.
(because I have a response.redirect "uploadform.htm" in uploadfile.asp used to let people upload more
file)

the mouse pointer is hourglass.
Thanks
Suying
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6471091
put the
response.buffer=true
on the top of the ASP page
0
 

Author Comment

by:suying
ID: 6471187
Hi Eyal,
the first two line in this page are including file:
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
 then I put the response.buffer=true on the third line.
do you mean I need put the response.buffer=true in front of including file?
Thanks
Suying
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6471217
yes.

this setting will tell the asp to hold all the output data in buffer until u do response.flash or the page ends its proccess
0
 

Author Comment

by:suying
ID: 6471340
Hi Eyal,
I still got the same error.
here is code for uploadfile.asp<% response.buffer=true %>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .</body></html>"
Response.Flush
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security
Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
     Response.Write "File(s) not uploaded."
Else
     ' Loop through the uploaded files
     For Each File In Uploader.Files.Items
                         
               ' Open the table you are saving the file to
      Set RS = Server.CreateObject("ADODB.Recordset")
        RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
           RS.AddNew ' create a new record
           RS("AttachID")=1
           RS("ARNumber")=Session("arnumber")
           RS("FileName")    = File.FileName
           RS("FileSize")=File.FileSize
           RS("ContentType")=File.ContentType
               ' Save the file to the database
           File.SaveToDatabase RS("Attachment")
         
               ' Commit the changes and close
           RS.Update
           RS.Close
         
         
     Next
End If
Response.Redirect "uploadform.htm"
%>
I think the error is caused by Response.Redirect "uploadform.htm"

any suggestion?
Thanks
Suying
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 3

Expert Comment

by:davlun20080
ID: 6471354
The problem I think is on the redirect, which is why I split the code in the second try, to try and keep the system from thinking it is receiving two sets of headers, one for the start of the html page and one for the redirect.

Also, the asp error you had from Eyal's code maybe due to a syntax error, I think.  Change the response.flash to response.flush and give it a try.

davlun
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6471380
davlun20080 is right its indeed Flush :) (10x 4 the correction)

if the redirect still doesn't work put this lines

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
   document.FormRedirect.submit();
<%Response.End%>
0
 

Author Comment

by:suying
ID: 6471442
Hi Davlun,
If I change the code as you told me, the Please Wait... didn't show and the monse pointer didn't change to hourglass( the code Eyal give is Flush not flash,sorry for typo error)here is the code in uploadfile.asp
here is code for uploadfile.asp

<% response.buffer=true %>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait..."

Response.Flush
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security

Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
                       
              ' Open the table you are saving the file to
     Set RS = Server.CreateObject("ADODB.Recordset")
       RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
          RS.AddNew ' create a new record
          RS("AttachID")=1
          RS("ARNumber")=Session("arnumber")
          RS("FileName")    = File.FileName
          RS("FileSize")=File.FileSize
          RS("ContentType")=File.ContentType
              ' Save the file to the database
          File.SaveToDatabase RS("Attachment")
         
              ' Commit the changes and close
          RS.Update
          RS.Close
         
         
    Next
End If
response.write "<script language=""javascript"">window.location.replace(""uploadform.htm"")</script></body></html>"
%>

Thanks
Suying
0
 

Author Comment

by:suying
ID: 6471473
Hi Eyal
Where to put your code,do I still need response.redirect"uploadform.htm

Thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6472574
OK, have done a little research and what I was surmising is true. You cannot use response.redirect after you have already sent the headers to the page.  Here is an excerpt from some literature explaining the response.redirect:

This method works by sending a 302 Object Moved status header to the browser.

All HTTP headers must be sent before any content is sent to the browser. If you disable buffering of script output and attempt to use this method after you have already sent content to the browser, FoxWeb will return an error message.

Any form of solution will need to involve processing in the client and a work around for sure.  Will try to work something out.

davlun
0
 

Author Comment

by:suying
ID: 6472608
Hi Davlun,
Thank you so much.I'm new to asp so I don't know too much. if you can help me out( I don't know if there is any solution for this), I will deeply appreciate.

Thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6475058
Not sure if this will work, hopefully it will.  Otherwise, you will need to use frames basically, submit in a hidden frame and then update the main page when you are finished.

This may or may not be compatible with the rest of your system...

davlun

*********  begin code here  ***********

<%@ Language=VBScript %>
<% Response.buffer = true %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please wait..."

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security
Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
     Response.Write "File(s) not uploaded."
Else
     ' Loop through the uploaded files
     For Each File In Uploader.Files.Items
                         
               ' Open the table you are saving the file to
      Set RS = Server.CreateObject("ADODB.Recordset")
        RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
           RS.AddNew ' create a new record
           RS("AttachID")=1
           RS("ARNumber")=Session("arnumber")
           RS("FileName")    = File.FileName
           RS("FileSize")=File.FileSize
           RS("ContentType")=File.ContentType
               ' Save the file to the database
           File.SaveToDatabase RS("Attachment")
         
               ' Commit the changes and close
           RS.Update
           RS.Close
         
         
     Next
End If

Response.write "<script language=""javascript"">window.setTimeout(""window.location.replace(""uploadform.htm"", 500)</script></body></html>"
Response.end

%>

0
 

Author Comment

by:suying
ID: 6475100
Hi davlun,
could you tell me where I should put the )in :
Response.write "<script language=""javascript"">window.setTimeout(""window.location.replace(""uploadform.htm"",
500)</script></body></html>"
Response.end
because I got the error said expert ")" with the line:
<html><head><title>Some Title</title></head><body style="cursor: wait">Please Wait . . .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>
I try to put .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>
or .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm",500))</script></body></html>
got the same error

Thanks
suying
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6475862
repolace the response.redirect with my code
0
 

Author Comment

by:suying
ID: 6477031
Hi Eyal,
when I replace the redirect with the code:

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
  document.FormRedirect.submit();
  -->

</script>
  <%Response.End%>
I got this error:
HTTP Error 405
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
(in your code, what the input type=hidden do?)
Thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6477276
Suying,
Use my code in it's entirety, exactly as it is written for your file uploadfile.asp.  Make sure you use the double quotes "" as that is the escape sequence in asp for outputing a single ".

Please post the entire error msg from my code if possible.  It looks like your response was munged a little bit.

davlun

NOTE FOR Eyal:
Before we propose more solutions that involve a redirect, please see my note above regarding how the redirect process works, it may help you help suying.  Unless you can find an exception somewhere, any form of redirect will not be allowed if you have already sent headers to the browser.

0
 

Author Comment

by:suying
ID: 6477367
Hi davlun,
here is the code you gave me:
<% Response.Buffer =true %>

<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->

<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . ."
.....
upload file code goes here
response.write "<script language=""javascript"">window.SetTimeOut(""window.location.replace(""editattach.htm""),500)</script></body></html>"
%>
when I run it, I get the page with Please Wait... and an error dialog box(small one) with Title Error and the content is:
A Runtime Error has Occurred. Do you wish to debug?
Line: 0
Error:Expected ')'

Yes    No
when I click the Yes button, it gave me the follow line :
<html><head><title>Some Title</title></head><body style="cursor: wait">Please Wait . . .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>

Suying

0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6477755
Ooops, even that code in a simple html file doesn't work, not sure why...exactly.

Try this:
   Replace the first part of the html written out with this:
      "<html><head><title>Some Title</title><script language=""JavaScript"">function replaceWin(){ window.location.replace('editattach.htm'); }</script></head><body style=""cursor: wait"" onload=""replaceWin()"">Please Wait . . ."

   and replace the bottom part with this:
      "</body></html>"

Maybe, just maybe this will work....

0
 

Author Comment

by:suying
ID: 6477786
Hi davlun,
if I change to the code you gave me, the mouse pointer did not change to hourglass.

Thanks
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6477875
Hmmm, then i am out of ideas.  Did the page relocate at the end of the processing?
0
 

Author Comment

by:suying
ID: 6477964
Hi davlun,
seems not.(Did the page relocate at the end of the processing? )
thank you so much.I will close this Q at the end of this week and give you the points(not too many,sorry)since you spent lot of time.

Thanks again
Suying
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6478186
sorry not able to help further.  wish i could of.
davlun
0
 
LVL 15

Expert Comment

by:Eyal
ID: 6478398
davlun20080:
because he did this in the code

response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait
. . .</body></html>"

I gave him a javascript that will do the trick(It works for me :)

suying:
the hidden input box is to support netscape problem (not allow empty forms)

do your browser have friendly errors marked?
I need more details on the error.
0
 

Author Comment

by:suying
ID: 6480323
Hi Eyal,
here is the error:
HTTP Error 405
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
is that the <form> tag must be inside of the <body> tag.
if I use the code:(which you gave me)

response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please

Wait . . .</body></html>
response.Flash

do upload work...

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
  document.FormRedirect.submit();
-->
</script>
<%Response.End%>
I got the above error.no more output tell my which line cause the error.

any suggestion?
Thanks
Suying

0
 
LVL 15

Expert Comment

by:Eyal
ID: 6485389
<%Response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .
response.Flush ' this will throw the message to the client browser

'do upload work...

'this will do the redirect method%>
<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
 document.FormRedirect.submit();
-->
</script>
</body></html>
<%Response.Flush
Response.End%>
0
 

Author Comment

by:suying
ID: 6487868
Hi Eyal,
got the same error.
Thanks
Suying
0
 
LVL 3

Accepted Solution

by:
davlun20080 earned 50 total points
ID: 6488295
Unless I am mistaken, Response.Write has the same effect as putting some html outside of the asp delimiters and then calling the Response.Flush method.  Response.write actually flushes the stream up to that point... I think.

I am very interested to see if Eyal is able to get this working since my research indicates any form of redirect is not possible after already sending headers to the page.

good luck all
0
 

Author Comment

by:suying
ID: 6495077
thanks for the effort. I will close this Q, if you have better idea please add comment here.

Thanks again.
0
 

Author Comment

by:suying
ID: 6495083
Thanks davlun,if you get better idea,please add a comment to that Q.
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6495091
sorry could not be of more service.  davlun
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now