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

RadAsyncUpload error in args.set_cancel(true);

8 Answers 358 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Davi
Top achievements
Rank 1
Davi asked on 03 Oct 2016, 02:22 PM

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.

8 Answers, 1 is accepted

Sort by
0
Davi
Top achievements
Rank 1
answered on 03 Oct 2016, 06:02 PM

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 = [];
    }
}

0
Anton
Telerik team
answered on 05 Oct 2016, 02:38 PM
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.
0
Davi
Top achievements
Rank 1
answered on 05 Oct 2016, 04:32 PM

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

0
Davi
Top achievements
Rank 1
answered on 05 Oct 2016, 05:15 PM
Here's the video.
0
Davi
Top achievements
Rank 1
answered on 05 Oct 2016, 05:23 PM

Sorry, here is the link to the video.

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

0
Anton
Telerik team
answered on 06 Oct 2016, 02:49 PM
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.
0
Davi
Top achievements
Rank 1
answered on 10 Oct 2016, 02:13 PM

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.

0
Anton
Telerik team
answered on 11 Oct 2016, 10:16 AM
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.
Tags
AsyncUpload
Asked by
Davi
Top achievements
Rank 1
Answers by
Davi
Top achievements
Rank 1
Anton
Telerik team
Share this question
or