on completion

Aug 6, 2009 at 12:33 PM

Hi. I have been playing around with this for a while now and really like the functionality it adds to my website.

Can you please let me know the easiest way to initiate an event once ALL the files have finished uploading? I see you have the IUploadedFileProcessor which is called each time an individual file is uploaded, but what about when ALL the files are uploaded?

Thanks.

Coordinator
Aug 6, 2009 at 6:44 PM
Edited Aug 6, 2009 at 6:44 PM

There is an onallfilesuploaded javascript event that can be handled for this purpose -- see Step 5 on the Example Usage page:

http://silverlightuploader.codeplex.com/Wiki/View.aspx?title=Example%20Usage

Here is an example of how you would do it as well:

 

window.onload = function() {

            // get the instance of UploaderControl that corresponds to the uploader1 server control
            var uploader1 = UploaderControl.getInstance("uploader1");
            
            // attach event handlers
            uploader1.attachEvent("onallfilesuploaded", uploader1_onallfilesuploaded);
        };
        
        // do some custom js code when all files have been uploaded
        function uploader1_onallfilesuploaded() {
           alert("done!");
        }

 

In that javascript method, you could send a request to the server to do some cleanup if necessary, or show a message to the user, etc.

I realize that it would also be convenient if the IUploadedFileProcessor interface would support a method that gets called directly on the server upon completion of all files.  I will put that on my to-do list and let you know when the change is available.  In the meantime, using the javascript method should be a viable workaround.

 

Aug 22, 2009 at 2:50 PM

cool! Thanks.