I have an instance of WebUpload control that I need to configure to fire the Upload events on the server side, but I still want to trap when the user selects files with the wrong extension on the client side.
In my ascx file, I have coded
<igjq:WebUpload ID="igUpload1" runat="server" OnUploadFinishing="igUpload1_OnUploadFinishing" OnUploadFinished="igUpload1_OnUploadFinished" OnUploadStarting="igUpload1_OnUploadStarting"> <ClientEvents OnError="showAlert" /> </igjq:WebUpload>
In the code behind (CS) file, I have
$.ig.loader(function () { $("#igUpload1").igUpload({ mode: 'multiple', multipleFiles: true, maxUploadedFiles: 5, maxSimultaneousFilesUploads: 1, allowedExtensions: ["txt", "doc", "png"], progressUrl: "Services/IGUploadStatusHandler.ashx", controlId: "serverID1", iguploadonerror: function (e, args) { showAlert(e, args); }, onError: function (e, args) { showAlert(e, args); } )};)};
When I code the OnUploadStarting to cancel the event with a server message, the onError event does fire and I can display the message there. This is good.
However, when I test the client side by selecting a file with a bad extension, neither error event fires.
What do I need to change to trap the OnError event on the client?
Hello Gerald,
Thank you for posting in our community!
Have you tested this scenario by using the errorMessageValidatingFileExtension option for the igUpload?
I have added a code snippet for your reference:
$(".selector").igUpload({
errorMessageValidatingFileExtension : "File extension not supported"
});
More information on error message types could be found at the option tab of the following page: http://help.infragistics.com/jQuery/2013.1/ui.igupload
If you have any further question feel free to contact me.
Dimka,
Thanks for your response, but I already have info on that errorMessage option.
My problem is that I have coded to allow three file extensions
allowedExtensions: ["txt", "doc", "png"]
but the upload control still allows me to pick a .html file and it uploads it.
I was expecting or hoping that the control would catch this and fire some error event where I could handle the message.
Gerald