How to trap when user clicks on cancel button

7 posts, 1 answers
  1. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 08 Feb 2011 Link to this post

    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
  2. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 10 Feb 2011 Link to this post

    Any idea how to do it ???
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 10 Feb 2011 Link to this post

    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.
  5. Mike
    Mike avatar
    5 posts
    Member since:
    Mar 2011

    Posted 03 Feb 2012 Link to this post

    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.
  6. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 08 Feb 2012 Link to this post

    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 >>
  7. Derek Swanson
    Derek Swanson avatar
    4 posts
    Member since:
    May 2010

    Posted 04 Nov 2012 Link to this post

    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
  8. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 07 Nov 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017