Getting Remote Files With ASP - The Code Client Script Initialization
(Page 3 of 5 )
Dim srvXmlHttp, xmlDOMDocument, objXMLList
Dim sServerURL, sKey, sClientVer, sGETData, sResponse
Dim iMessage, sVersion, sCode, fsoFileObject
Set srvXmlHttp = server.createobject("Msxml2.serverXmlHttp")
Set xmlDOMDocument = Server.CreateObject("Msxml2.DOMDocument.4.0")
sServerURL = "http://www.yoururl.com/ASPFree/Server/Default.asp"
sKey = "1234abcd"
sClientVer = "1.234"
sGETData = "sGenKey=" & sKey & "&sCurrentVersion=" & sClientVer
Const C_TEXT = 1
Const C_BINARY = 2
Const E_UPDATESCRIPTFAILURE = 3
The sServerURL is the full URL to the location you put the server script. The sGETData combines the client key and current version (which I suggest you store in a config file and read each time you do the update), and you can throw in whatever data you would like to send the server via the QueryString. This can be used by the server to validate licenses, learn information about the client, or modify the server itself.
Now we briefly display an "updating" message to the client while the update routines are called, and the work is being done. For some reason, it’s always comforting to see a progress bar, even if it’s only an animated gif!
Call DisplayPage()
Sub DisplayPage()
%>
<form name="UpdateForm">
<img src="Images/progressbar.gif" name="UpdateImage">
<br>
<input type="text" name="UpdateText" value=""
Readonly="readonly" size="100" />
</form>
<%
End Sub
Response.Write(vbCrLf & "<script language=""JavaScript"">" & _
VbCrlf & VbCrlf & _
"document.UpdateForm.UpdateText.value = +" & _
"'Auto-Updating...Please Wait...';" & _
VbCrlf & VbCrlf & _
"</script>")
So now that the user knows the update is happening, we call the routine. Once that is finished, we update the progress bar and field:
Call PerformUpdate()
Response.Write(vbCrLf & "<script language=""JavaScript"">" & _
VbCrlf & VbCrlf & _
"document.UpdateForm.UpdateText.value = 'Done!';" & _
VbCrlf & VbCrlf & _
"</script>")
Response.Write(vbCrLf & "<script language=""JavaScript"">" & _
VbCrlf & VbCrlf & _
"document.UpdateImage.src = 'Images/Blank.gif';" & _
VbCrlf & VbCrlf & _
"</script>")
Next: PerformUpdate() Explained >>
More ASP Articles
More By Justin Cook