The following table is generated by recording all of the events that are triggered by uploading two files with the XFRequest object. The table can be used to compare when the different events occur and in what order. The code for generating this table is available as an attachment to this article. A similar code sample is provided for the AXFFile object.
-
Demonstration: Use the TransferStatusChange Event to notify the User when the complete transfer is finished. XFile object used: Transfer-Engine only (XFRequest).
Instantiate the XFRequest object in the <BODY> tag of your HTML code.
<OBJECT CLASSID="clsid:C3A57B60-C117-11D2-BD9B-00105A0A7E89"
codebase="http://DomainName/XFileApplicationDirectory/SAXFile.cab"
ID="XFILE">
</OBJECT>
In a <SCRIPT> tag, provide the event handler for the TransferStatusChange event. Note, than since ID attribute of XFile's object tag has the value of "XFILE", your event handler will be pre-pended with "XFILE_".
<SCRIPT language = 'vbs'>
Sub XFILE_TransferStatusChange( ByVal code, ByVal Message )
If code = 7 then
msgbox Message
End if
</SCRIPT>
End Sub
In the above code snippet, if the TransferStatusChange event handler receives a status code of "7", it will display the associated message, "Transfer is complete" in a pop-up message box.
- Demonstration: Use the StatusTransferChange Event to notify the User when the complete transfer is finished. XFile object used: Visual Upload Control/GUI (AXFFile).
The TransferStatusChange event represents work done by the Transfer Engine (the XFRequest object). XFile's visual control does not have direct access to this event, so you must call a method to add the event handler and create a subroutine that matches the signature of
TransferStatusChange(Code As Integer, Message As String)
that will be called by the XFRequest object when a TransferStatusChange event occurs.
Instantiate the AXFFILE object in the <BODY> tag of your HTML code.
<OBJECT classid="CLSID:230C3D02-DA27-11D2-8612-00A0C93EEA3C"
height="200"
codebase="http://DomainName/XFileApplicationDirectory/SAXFile.cab"
id="GUI_XFILE"
style="HEIGHT: 200px; LEFT: 0px; TOP: 0px; WIDTH: 400px"
width="400"
VIEWASTEXT>
<!-- DISABLE the upload button so that we can create our own and run code off of it -->
<PARAM NAME="EnableUploadButton" VALUE="0">
</OBJECT>
<INPUT Type=Button Name="UploadButton" value="Start Upload">
Create a subroutine that will function as an event handler. It can be named as you choose, but it must be able to accept two parameters to accomodate the event code and event message.
<SCRIPT language='vbs'>
'--- This is the sub we will use to handle the XFRequest object's TransferStatusChange events.
'--- This sub needs to be able to handle
'--- the same parameters as that event it is linked to:
'--- the code and the message returned from the XFRequest's
'--- TransferStatusChange event
Sub DisplayTheStatusChanges(code,message)
If code = 7 then
msgbox message
End if
End Sub
</SCRIPT>
Call the AddTransferStatusChangeEventHandler method of the XFRequest object. Pass it the name of the subroutine that will handle the events. By doing so, the events can now be reported even though the Start method is being called on the AXFFile object.
<SCRIPT language = 'vbs'>
Sub UploadButton_onClick()
'--- Set the URL where we want to send the data by
'--- using the CurrentURL property
Dim XFILE
Set XFILE = GUI_XFILE.XFRequest
XFILE.AddTransferStatusChangeEventHandler(GetRef("DisplayTheStatusChanges"))
...other xfile code
GUI_XFILE.Start
End Sub
</SCRIPT>