RadAsyncUpload error in args.set_cancel(true);

9 posts, 0 answers
  1. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 03 Oct Link to this post

    I have a problem when using the args.set_cancel command (true), to cancel the upload.

    Code RadAsyncUpload:

    <telerik:RadAsyncUpload

                    ID="radFileUpload"
                    MaxFileSize="10000000"
                    OnClientFilesSelected="OnClientFilesSelected"
                    HttpHandlerUrl="~/UploadFiles.ashx"
                    TemporaryFolder="~/upload"
                    MaxFileInputsCount="1"
                    runat="server">
                </telerik:RadAsyncUpload>

     

    Code Javascript:

    function OnClientFilesSelected(sender, args) {            

                if ((sender._uploadedFiles.length + args.get_count()) > sender._maxFileCount) {
                    args.set_cancel(true);
                    alert('The maximum number of file(s) to upload is: ' + sender._maxFileCount);
                }
    }

     

    The problem is that when the seto args.set_cancel to TRUE, the upload component does not finciona more. By clicking on the button to upload, it does not respond anymore. This is the version 2016.2.504.45. In version 2015.1.401.45 it works normally.

  2. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 03 Oct in reply to Davi Link to this post

    A solution I found to get around this problem was:

    I wonder when you release a version of correction?

    <telerik:RadAsyncUpload
                    ID="radFileUpload"
                    MaxFileSize="10000000"
                    OnClientFilesUploaded="OnClientFilesUploaded"
                    OnClientFilesSelected="OnClientFilesSelected"
                    OnClientFileUploading="OnClientFileUploading"
                    HttpHandlerUrl="~/UploadFiles.ashx"
                    TemporaryFolder="~/upload"
                    MaxFileInputsCount="1"
                    runat="server">
                </telerik:RadAsyncUpload>
                 
    function OnClientFilesUploaded() {
        if(isCanceled &&
        elements.length > 0) {
            $.each(elements, function(index, value) {
                $(value._row).find('input[name="RowRemove"]').click();
            });
        }
     
    }
     
    function OnClientFilesSelected(sender, args) {   
        if ((sender._uploadedFiles.length + args.get_count()) > sender._maxFileCount) {
            isCanceled = true;
            alert('The maximum number of file(s) to upload is: ' + sender._maxFileCount);
        }else {
            isCanceled = false;
        }
    }
     
    var elements = [];
    function OnClientFileUploading(sender, args) {   
        if (isCanceled) {
            elements.push(args);   
        }else{
            elements = [];
        }
    }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anton
    Admin
    Anton avatar
    58 posts

    Posted 05 Oct Link to this post

    Hello Davi,

    I have recorded the following video which shows the RadAsyncUpload, setup with OnClientFilesSelected and canceling the upload within the client-side event with set_cancel(true). As you can see at my end the uploading is canceled as it should.
    I'm using version 2016.2.504.45.

    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 05 Oct Link to this post

    Hi Anton,

    Attached the video that I did.

    I did not express myself very well in relation to the problem occurred.

    The command 'args.set_cancel (true);' works yes, however when using the command and then try to add a new file, it does not add, or upload no more anexma any files.

    In my case I add a validation. Our upload for example can only be inserted 5 files, if user add 6 files, the system validates and bar the action using the 'args.set_cancel (true);'.

    If you put 6 files the system cancels the action and displays a message, causing the user to add only 5 files. After the validation is performed and the user attempts to re-add other files, the upload does not add the files in the list.

    Try to simulate the implementation below, filling methods.

     

    01.<telerik:RadAsyncUpload
    02. 
    03.                ID="radFileUpload"
    04.                MaxFileSize="10000000"
    05.                OnClientFilesSelected="OnClientFilesSelected"
    06.                HttpHandlerUrl="~/UploadFiles.ashx"
    07.                TemporaryFolder="~/upload"
    08.                MaxFileInputsCount="5"
    09.                MultipleFileSelection="Automatic"
    10.                runat="server">
    11.            </telerik:RadAsyncUpload>
    12. 
    13.  
    14. 
    15. 
    16.function OnClientFilesSelected(sender, args) {           
    17. 
    18.            if ((sender._uploadedFiles.length + args.get_count()) > sender._maxFileCount) {
    19.                args.set_cancel(true);
    20.                alert('The maximum number of file(s) to upload is: ' + sender._maxFileCount);
    21.            }
    22.}

  6. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 05 Oct Link to this post

    Here's the video.
  7. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 05 Oct in reply to Davi Link to this post

    Sorry, here is the link to the video.

    https://www.youtube.com/watch?v=R9eQ0v_15S4

  8. Anton
    Admin
    Anton avatar
    58 posts

    Posted 06 Oct Link to this post

    Hello Davi,

    Unfortunately I was unable to reproduce the issue you're facing. I used the code you've provided and followed the steps shown in your video, but at my side it seems to work as it should. Please take a look at the video I've recorded and let me know if additional steps need to be followed in order for the problem to be reproduced.

    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. Davi
    Davi avatar
    6 posts
    Member since:
    Oct 2016

    Posted 10 Oct Link to this post

    Hi Anton, 

    The video you have done is correct so, follow all the steps correctly. I would like me to send this project that you used to record video?

    Thank you very much.

  10. Anton
    Admin
    Anton avatar
    58 posts

    Posted 11 Oct Link to this post

    Hello Davi,

    I'm attaching the page I tested with.

    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017