ActiveXPowUpload 1.0.1 control documentation

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 


Some important builtin DHTML events:

onactivate event

Own events:

OnAddFiles event

OnDropItems event

OnDropItems event

OnUploadClicked event

OnUploadBegin event

OnUploadFileBegin event

OnUploadProgress event

OnUploadFileCompleted event

OnUploadFinishedBeforeReply event

OnUploadCompletedSuccessfully event

OnUploadCancelled event

OnServerError event

OnError event

OnMessage event

OnSort event

OnLog event


onactivate

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.

Example

<script for="ActiveXPowUpload" event="onactivate()" language="JavaScript">
//Any initialization code here
</script>

OnAddFiles

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.

Parameters

NumberOfItems:Long - Number of items added, files and folders.

NumberOfFiles:Long - Number of files added.

TotalSize:Long - Total size of added files.

Example

<script for="ActiveXPowUpload" event="OnAddFiles(NumberOfItems, NumberOfFiles, TotalSize)" language="JavaScript">
window.alert("added files count " + NumberOfFiles + ", total size=" + TotalSize);
</script>

OnDropItems

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.

Parameters

NumberOfItems:Long - Number of items dropped.

Example

<script for="ActiveXPowUpload" event="OnDropItems(NumberOfItems)" language="JavaScript">
window.alert("Dropped items count " + NumberOfItems);
</script>

OnRemoveFiles

event OnRemoveFiles(NumberOfItems:Long, NumberOfFiles:Long, TotalSize:Long) {}

Invoked after items removed from the list.

Parameters

NumberOfFiles:Long - Number of items removed, files and folders.

NumberOfFiles:Long - Number of files removed.

TotalSize:Long - Total size of the removed files.

Example

<script for="ActiveXPowUpload" event="OnRemoveFiles(NumberOfItems, NumberOfFiles, TotalSize)" language="JavaScript">
window.alert("Removed files count " + NumberOfFiles + ", total size=" + TotalSize);
</script>

 

OnUploadClicked

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.

Example

<script for="ActiveXPowUpload" event="OnUploadClicked()" language="JavaScript">
ActiveXPowUpload.AddFormItem("username", "Jdoe");
</script>

OnUploadBegin

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.

Example

<script for="ActiveXPowUpload" event="OnUploadBegin()" language="JavaScript">
window.alert("Upload begin!");
</script>


OnUploadFileBegin

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).

Parameters

FileName:String - Full path of the file that is started to upload.

Example

<script for="ActiveXPowUpload" event="OnUploadFileBegin(FileName)" language="JavaScript">
window.alert("Uploading file " + FileName);
</script>

OnUploadProgress

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.

Parameters

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.

Example

<script for="ActiveXPowUpload" event="OnUploadProgress(CurrentPartName, CurrentPartSize, CurrentPartBytesUploaded, TotalSize, TotalBytesUploaded, ElapsedTime, LeftTime, CurrentSpeed, AverageSpeed)" language="JavaScript">
//Code here
</script>

 



OnUploadFileCompleted

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.

Parameters

FileName:String - Full path of file that was uploaded.

Example

<script for="ActiveXPowUpload" event="OnUploadFileCompleted(FileName)" language="JavaScript">
window.alert("Uploaded file " + FileName);
</script>

OnUploadFinishedBeforeReply

event OnUploadFinishedBeforeReply() {}

Event occurs immediately after all data have been uploaded but don't got server reply (waiting it).

Example

<script for="ActiveXPowUpload" event="OnUploadFinishedBeforeReply()" language="JavaScript">
window.alert("Upload finished, please wait for server reply!");
</script>


OnUploadCompletedSuccessfully

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.

Example

<script for="ActiveXPowUpload" event="OnUploadCompletedSuccessfully()" language="JavaScript">
window.alert("Upload finished successfully! Server reply: " + ActiveXPowUpload.GetServerReply(65001));
</script>

OnUploadCancelled

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.

Example

<script for="ActiveXPowUpload" event="OnUploadCancelled()" language="JavaScript">
window.alert("Upload cancelled!");
</script>

OnServerError

event OnServerError() {}

Invoked if server returned HTTP error while starting or finishing request. Use GetServerReply, GetServerStatusCode and GetServerStatusText methods to get reply content.

Example

<script for="ActiveXPowUpload" event="OnServerError()" language="JavaScript">
window.alert("Error occured: " + ActiveXPowUpload.GetServerReply(65001));
</script>

OnError

event OnError(Error:String) {}

Invoked if something error occured. This event don't fires if HTTP error occures. HTTP errors rises OnServerError event.

Parameters

Error:String - The description of error.

Example

<script for="ActiveXPowUpload" event="OnError(Error)" language="JavaScript">
window.alert("Error occured: " + Error);
</script>

OnMessage

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.

Parameters

Message:String - Message description.

Example

<script for="ActiveXPowUpload" event="OnMessage(Message)" language="JavaScript">
window.alert("Message received: " + Message);
</script>

OnSort

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.

Parameters

column:Long - column number. 0 - file name column, 1 - file size column.

Example

<script for="ActiveXPowUpload" event="OnSort(col)" language="JavaScript">
window.alert("File list has been sorted on " + col + " column");
</script>

OnLog

event OnLog(message:String) {}

Gets debug messages.

Parameters

Message:String - debug message.

See also debug.

Example

<script for="ActiveXPowUpload" event="OnLog(msg)" language="JavaScript">
   events.value = events.value + "OnLog(" + msg + ")\n"
</script>

<TEXTAREA NAME="events" ROWS=10 COLS=100>
</TEXTAREA>