ActiveXPowUpload supports its own events and builtin DHTML events.
1. You can find a lot of DHTML events at a MSDN website http://msdn2.microsoft.com/en-us/library/ms533051(VS.85).aspx
For example for the "onkeydown()" DHTML event use the following sample code:
<script for="ActiveXPowUpload" event="onkeydown()" language="JavaScript">
//Code here
</script>
In the code inside you can call JavaScript event object methods and properties to get more information about the occurred event.
2. To use own ActiveXPowUpload events add the following sample code to the page:
<script for="ActiveXPowUpload" event="OnError(Error)" language="JavaScript">
window.alert(Error);
</script>
All own ActiveXPowUpload events are listed below.
ActiveXPowUpload object events
event onactivate() {}
Builtin DHTML event. Fires when the object is set as the active element. This event helpfull if you want to call ActiveXPowUpload properties or methods right away after it will loaded. It is impossible to call any ActiveXPowUpload code before user will make "Click to activate" or workaround will be loaded. This event fires after control loaded and "Click to activate" done.
<script for="ActiveXPowUpload" event="onactivate()" language="JavaScript">
//Any initialization code here
</script>
event OnAddFiles(NumberOfItems:Long, NumberOfFiles:Long, TotalSize:Long) {}
Invoked after new files or folders added to list. ActiveXPowUpload doesn't add files that are already in the list. If file is already in the list, all information related to it updated. File saves its position in the file list i.e. index left unchanged.
New are files added to the end of the list so you can enumerate new files by index: from ActiveXPowUpload.FileListItemCount-1 down to ActiveXPowUpload.FileListItemCount-NumberOfItems-1.
NumberOfItems:Long
- Number of items added, files and folders.
NumberOfFiles:Long
- Number of files added.
TotalSize:Long
- Total size of added files.
<script for="ActiveXPowUpload" event="OnAddFiles(NumberOfItems, NumberOfFiles, TotalSize)" language="JavaScript">
window.alert("added files count " + NumberOfFiles + ", total size=" + TotalSize);
</script>
event OnDropItems(NumberOfItems:Long) {}
Invoked after files were dropped (drag-n-drop) on the component. NumberOfItems is not the same as number of files! If user copies one folder to clipborad, NumberOfItems will be 1, regardless of the number of files in that folder.
NumberOfItems:Long
- Number of items dropped.
<script for="ActiveXPowUpload" event="OnDropItems(NumberOfItems)" language="JavaScript">
window.alert("Dropped items count " + NumberOfItems);
</script>
event OnRemoveFiles(NumberOfItems:Long, NumberOfFiles:Long, TotalSize:Long) {}
Invoked after items removed from the list.
NumberOfFiles:Long
- Number of items removed, files and folders.
NumberOfFiles:Long
- Number of files removed.
TotalSize:Long
- Total size of the removed files.
<script for="ActiveXPowUpload" event="OnRemoveFiles(NumberOfItems, NumberOfFiles, TotalSize)" language="JavaScript">
window.alert("Removed files count " + NumberOfFiles + ", total size=" + TotalSize);
</script>
event OnUploadClicked() {}
Invoked immediately after an Upload popup menu item clicked or an Upload method called. You can add custom text Form items at the event handler because POST request is not formed at that time.
<script for="ActiveXPowUpload" event="OnUploadClicked()" language="JavaScript">
ActiveXPowUpload.AddFormItem("username", "Jdoe");
</script>
event OnUploadBegin() {}
Invoked after an upload process starts. You can't change Script path or add text Form items after this event occured because POST request already formed and started.
<script for="ActiveXPowUpload" event="OnUploadBegin()" language="JavaScript">
window.alert("Upload begin!");
</script>
event OnUploadFileBegin(FileName:String) {}
Invoked when individual file body starts to upload. All files in the list are sent in a single POST request. While a part of the request containing individual file body uploads this event occures. You can use this event to let a user know which files was already uploded and the file that is uploaded right now. Some of server side scripts can save files that was uploaded even if a whole request not uploaded (See our product PowUpload ASP.NET server control).
FileName:String
- Full path of the file that is started to upload.
<script for="ActiveXPowUpload" event="OnUploadFileBegin(FileName)" language="JavaScript">
window.alert("Uploading file " + FileName);
</script>
event OnUploadProgress(CurrentPartName:String, CurrentPartSize:Long, CurrentPartBytesUploaded:Long, TotalSize:Long, TotalBytesUploaded:Long, ElapsedTime:Long, LeftTime:Long, CurrentSpeed:Double, AverageSpeed:Double) {}
Invoked periodically during the upload process. POST request has RFC 1867 format. It consists of text Form items at the begin with some header data and then files body, each with some header data at the begin. At the end of the request there are few bytes of a closing boundary.
CurrentPartName:String
- Name of currently uploaded part of request. It can be 1. "<text fields>" if text Form items uploaded, 2. Full file path if file uploaded or 3. Empty string if final boundary uploaded.
CurrentPartSize:Long
- Total size of currently uploaded part of request, in bytes. For files it is size of file + header data size.
CurrentPartBytesUploadedLong
- Already uploaded size of currently uploaded part, in bytes.
TotalSize:Long
- Total size of whole request, in bytes.
TotalBytesUploaded:Long
- Already uploaded size of request, in bytes.
ElapsedTime:Long
- How many time has elapsed since the upload starts, in milliseconds. Divide this value by 1000 to get seconds.
LeftTime:Long
- How many time left to finish upload based on the average speed, in milliseconds.
CurrentSpeed:Double
- Current speed of the upload, in bytes per second.
AverageSpeed:Double
- Average speed of the upload, in bytes per second.
<script for="ActiveXPowUpload" event="OnUploadProgress(CurrentPartName, CurrentPartSize, CurrentPartBytesUploaded, TotalSize, TotalBytesUploaded, ElapsedTime, LeftTime, CurrentSpeed, AverageSpeed)" language="JavaScript">
//Code here
</script>
event OnUploadFileCompleted(FileName:String) {}
Invoked after individual file fully uploaded. All files at list sends in single POST request. After part of request containing individual file body uploaded this event occures.
FileName:String
- Full path of file that was uploaded.
<script for="ActiveXPowUpload" event="OnUploadFileCompleted(FileName)" language="JavaScript">
window.alert("Uploaded file " + FileName);
</script>
event OnUploadFinishedBeforeReply() {}
Event occurs immediately after all data have been uploaded but don't got server reply (waiting it).
<script for="ActiveXPowUpload" event="OnUploadFinishedBeforeReply()" language="JavaScript">
window.alert("Upload finished, please wait for server reply!");
</script>
event OnUploadCompletedSuccessfully() {}
Invoked after upload was finished and server sents OK reply. If upload wasn't success then OnServerError event occures. Use GetServerReply, GetServerStatusCode and GetServerStatusText methods to get reply content.
<script for="ActiveXPowUpload" event="OnUploadCompletedSuccessfully()" language="JavaScript">
window.alert("Upload finished successfully! Server reply: " + ActiveXPowUpload.GetServerReply(65001));
</script>
event OnUploadCancelled() {}
Invoked when the upload process discovers the cancel request. Upload stops, a connection with the server is closed. The OnUploadCancelled event followed by an OnError event. The message of the OnError event will state the upload was cancelled. The GetServerReply, GetServerStatusCode and GetServerStatusText methods do not return anything useful in this case.
<script for="ActiveXPowUpload" event="OnUploadCancelled()" language="JavaScript">
window.alert("Upload cancelled!");
</script>
event OnServerError() {}
Invoked if server returned HTTP error while starting or finishing request. Use GetServerReply, GetServerStatusCode and GetServerStatusText methods to get reply content.
<script for="ActiveXPowUpload" event="OnServerError()" language="JavaScript">
window.alert("Error occured: " + ActiveXPowUpload.GetServerReply(65001));
</script>
event OnError(Error:String) {}
Invoked if something error occured. This event don't fires if HTTP error occures. HTTP errors rises OnServerError event.
Error:String
- The description of error.
<script for="ActiveXPowUpload" event="OnError(Error)" language="JavaScript">
window.alert("Error occured: " + Error);
</script>
event OnMessage(Message:String) {}
Fired when an event happened the user should know about. E.g. some files have been skipped when a group of files were added to the file list.
Message:String
- Message description.
<script for="ActiveXPowUpload" event="OnMessage(Message)" language="JavaScript">
window.alert("Message received: " + Message);
</script>
event OnSort(column:Long) {}
Fired after the file list is sorted. It usually happens when an user clicks on the header of some of the columns.
column:Long
- column number. 0 - file name column, 1 - file size column.
<script for="ActiveXPowUpload" event="OnSort(col)" language="JavaScript">
window.alert("File list has been sorted on " + col + " column");
</script>
event OnLog(message:String) {}
Gets debug messages.
Message:String
- debug message.
See also debug.
<script for="ActiveXPowUpload" event="OnLog(msg)" language="JavaScript">
events.value = events.value + "OnLog(" + msg + ")\n"
</script>
<TEXTAREA NAME="events" ROWS=10 COLS=100>
</TEXTAREA>