We have a RadAsyncUpload located in a custom menu-like component (a div that is displayed/hidden with a client script).
When this div is hidden (user is clicking a close button), we want to cancel all uploads that are currently active.
We have did this by calling deleteAllFileInputs() function on the async upload, this did seem to work, but I noticed that the actual upload is not canceled when calling this method, it is still running in the background and other client events might be called (such as OnClientFileUploadFailed)...
Is there any other way to actually cancel all current uploads with a client script?
10 Answers, 1 is accepted
Well this is not what we want, we already has limited to one file, so there is already a cancel button (the one included in the RadAsyncUpload).
We have a script that is hiding the entire upload control, and when that happens all uploads should be canceled.
Seems natural that the deleteAllFileInputs() also cancels the upload, but it doesn't...
The entire area where the upload control i located may be hidden from multiple places, for example by clicking besides it (functions like a RadMenu). When it is set to hidden, we also want to cancel the upload, is there any way to do this in a script?
One way is of course to look for all cancel buttons and invoke a click on the button, but is there a more simple way of doing this?
Or will you fix so that the deleteAllFileInputs() also cancels the upload?
Would you please set the DisablePlugins="true" property in RadAsyncUpload and try to delete the uploading files as in the code below and let us know if you still observe the unusual behavior please elaborate a little bit what should we add or do in order to reproduce it because it is not very clear so far:
Hope this will be helpful.Greetings,
the Telerik team
In your example the upload does actually stop when clicking the button, but that is not because you called the deleteAllInputFiles(), it is because in your example the button does a full postback of the page...
In your example, try setting AutoPostBack="false" on the button, then you will see it clearly in for example Fiddler, that the upload continues. Even the OnClientFileUploaded event will be called after the button was clicked...
Try this example with a large file (so you can click the button before it finishes):
Thank you for elaborating the issue.
This seems like the delete inputs function is not working properly in such scenario and in these case we recommend invoking click event (by using jQuery for example). Please excuse us for the inconvenience caused by this issue.
We will do our best to research and fix the issue for the future versions.
the Telerik team
I have tested the code provided by Caesar and it properly deleted all the uploading files. If you only want to cancel the upload you can use the following code:
Please let me now if in any particular case these scenarios are not working properly so we could inspect them once again.
All the best,
the Telerik team
I am having a JS runtime error: Unable to delete property 'file' of undefined or null reference when implementing your code.
What I am trying to do is to put the radProgressArea (within a bootstrap modal popup) in master page. The radasyncupload control will launch the modal popup in the onClientfileUploading event, and closing it with the event of OnClientFilesUploaded.
So, I will need a "Cancel" button on the modal popup in order to cancel the uploading process of the radasyncupload control.
When I implemented your code, it gives me a JS runtime error as descripted above.
Could you please let me know how to cancel the uploading process in script?
thanks a lot,
The scenario is quite custom and we are not aware of such issue with the control. If you can isolate it to an issue in our control please share the exact code so we could inspect it and be more helpful.
Telerik by Progress