I want show a message in client when server is triggering an custom error upon uploading but i just cant get it to work. I can trigger other events and but i just cant get custom errors to work. Im using ASP.Net MVC and the ASP.NET MVC Helper.
How do i trigger a custom error from my controller and show the error in the client?
Server controller:
internal static void HandlerUploadFinising(object sender, UploadFinishingEventArgs args)
{
args.ServerMessage = "An error";
args.Cancel = true;
}
Client:
$("#imageUpload").bind({
iguploadfileuploaded: function (e, args) {
console.log('iguploadfileuploaded ', args);
});
Hello,
Thank you for using our forum.
You can handle event iguploadonerror, and from there to show every error message.
Below you can find online sample regarding this:
http://igniteui.com/file-upload/aspnet-mvc-helper
Code snippet:
I have implemented that callback, maybe i was a bit unclear in my first question but i was unable to get this to work properly.
How do i throw an custom error in the controller so it cant be shown in the client?
For an example, i want to check the resolution of a png file and run viruscheck after the file is uploaded.
If there is a working example of this scenario of this?
Hello Pytte,
Let me correct myself, this issue is fixed and available in the last Service Release. I am attaching you a sample that is showing how to throw a custom error and show it in your view.
I hope that you will glad this approach.
Please have a look and let me know if you have any further questions.
I finally got it to work. Thanks for your example. The problem was in my web.config, it pointed to an older version of Infragistics.Web.Mvc.dll that i had referenced.
The next question is, how can i trigger file specific error messages when i upload multiple files?
If i want to upload 10 different files and 2 files generates two different errors, how can i show the specific message to just that file?
Hey pytte,
In order to handle different uploaded files my suggestion is to configure your Upload Wrapper like:
@(Html.Infragistics().Upload() .ID("upload1") .ControlId("upload1") .MultipleFiles(false)
.Mode(UploadMode.Multiple) .AutoStartUpload(false) .Render() )
Just set MultipleFiles to be false and Mode to be Multiple. Now the event will fire for each uploaded file and you can return different message for each of them.