This is a migrated thread and some comments may be shown as answers.

How to trap when user clicks on cancel button

6 Answers 182 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Vasssek
Top achievements
Rank 1
Vasssek asked on 08 Feb 2011, 11:22 AM
Hello Telerik Team,

I have one issue with radasyncupload control. I need to trap event when user clicks on cancel button during uploading of a file. I didn't find any onclient method which could allow this.

Do you have an idea, how to solve it ?

For further information please check the attachment of this message.

Thank you.

Vasssek

6 Answers, 1 is accepted

Sort by
0
Vasssek
Top achievements
Rank 1
answered on 10 Feb 2011, 01:51 PM
Any idea how to do it ???
0
Accepted
Dimitar Terziev
Telerik team
answered on 10 Feb 2011, 04:00 PM
Hello Vasssek,

There is no event which is fired when this "cancel" button is clicked, but you could subscribe on the "click" event and put your logic into the event handler function. In order to subscribe on the click event use the following implementation:
function pageLoad() {
 
    var upload = $find("RadAsyncUpload");
 
    $telerik.$(".ruCancel", upload.get_element()).live('click', function() {
 
        alert('User clicked on cancel');
 
    });
}

 I hope you will find this approach useful.

All the best,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Mike
Top achievements
Rank 1
answered on 03 Feb 2012, 02:28 PM
That is a nice way to handle the cancel event. Can you tell me how, client-side, I can then reset the AsynchUpload control back to the "select a file" mode?

Thanks.
0
Dimitar Terziev
Telerik team
answered on 08 Feb 2012, 01:45 PM
Hello Mike,

If you want to delete the input with the canceled file you should get a reference to the RadAsyncUpload and then call its deleteFileInputAt  method:
async.deleteFileInputAt(0)


Regards,
Dimitar Terziev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Derek Swanson
Top achievements
Rank 2
answered on 04 Nov 2012, 11:26 PM
The async.deleteFileInputAt(0) works nicely if I want to remove a file with the cancel button, but only if there if one file.  How can I determine which file to remove if there are multiple files with the cancel button?  For example, say a user is uploading 10 files and tries to cancel the 5th file, how can I get the row/position of the 5th file to remove that file?  From the code so far I have everything working except this part.  Any ideas?  Thanks!

Cheers,
Derek
0
Dimitar Terziev
Telerik team
answered on 07 Nov 2012, 10:35 AM
Hi Derek,

Once the cancel button is clicked and the event handler function is invoked, one you could check the index of the target element and use it with the  deleteFileInputAt method. In order to get the index of the current element, the jQuery index() method could be used. Here is a sample implementation:
function pageLoad() {
 
               var async = $find("RadAsyncUpload1");
               $telerik.$(".ruCancel", async.get_element()).live('click', function () {
                   var $element = this,
                       index = $telerik.$(".ruButton", async.get_element()).index($element);
 
                   async.deleteFileInputAt(index);
               });
           }


Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
AsyncUpload
Asked by
Vasssek
Top achievements
Rank 1
Answers by
Vasssek
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Mike
Top achievements
Rank 1
Derek Swanson
Top achievements
Rank 2
Share this question
or