Im using the following in view:
@(Html.Telerik().Upload() .Name("attachment") .Multiple(false) .Async(async => async .Save("Save", "UploadFiles") .AutoUpload(true) ) .ClientEvents(events => events .OnError("onError")))
and controller:
public ActionResult Save(IEnumerable<HttpPostedFileBase> attachment) { foreach (var file in attachment) { <code> } }
However, the controller action is called twice, when I submit one file. It works fine if i disable autoupload. Im using IE 8. Any ideas?
Secoundly I want to customize my error msg. Im parsing the file, and wants to return specific error msg to the view telling the user exactly what went wrong. How can I archive this?
Thanks!
10 Answers, 1 is accepted
My test showed that the Save action fires only once per file. This is the first report of such problem so far.
The error message can be customized by handling the OnError client-side event.
I hope this helps.
Tsvetomir Tsonev
the Telerik team
I did get the onUpload event firing twice and after spending a day on the issue it was related to other input controls hooked up to their events via the jquery live method. The time I change from live to bind, it started firing once.
Hope this helps.
Regards,
I am having the same problem as the OP here.
The Save event as well as the clientside 'onSelect' event get called twice when using the upload control in IE8 and using the jQuery 'live' function to bind a 'change' event to an input. Changing the 'live' to 'bind' solves this as does changing the event registered on the input to another function (such as keyup). But obviously these are workarounds and don't solve the problem.
It seems to work ok in Chrome and I think it's fine in Firefox (not tested properly) so I think it is IE specific.
Thank you for sharing additional details about this issue. We were able to confirm the problem under IE8 and trace it down to a bug in jQuery - #6593
It seems to affect all change event handlers, not just those attached through jQuery. This almost completely rules out the possibility of a fix in the Upload.
We'll monitor the progress of this jQuery issue for a possible workaround or a permanent fix.
Greetings,
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
We'll make sure the MVC extensions work with jQuery 1.7 once it nears release.
The integrated version will be updated, but not immediately. We want to give customers time to familiarize themselves with the breaking changes introduced in jQuery (if any).
Tsvetomir Tsonev
the Telerik team
Any idea when this is going to be fixed and released. (IE 8 issues)
Currently upload control has following issues based on below implementation
<%
= Html.Telerik().Upload()
.Name("attachments")
.Multiple(true)
.Async(async => async
//controller action while uploading file
.Save(
"UploadFile", "ControllerName")
//controller action while removing selected file
.Remove(
"RemoveFile", "ControllerName")
.AutoUpload(true))
.ClientEvents(c => c.OnSuccess("onFileUploadSuccess") .OnError("onFileUploadError"))
%>
Issues
1 ) 'onFileUploadSuccess" fired twice (client event, even onSelect, or any other event does have same issue)
2) Save("UploadFile", "ControllerName") fired twice (Server event)
3) File List ("t-upload-files") has duplicate file names. (UI displaying uploaded file)
Browser : IE 8
I see the info on handling the OnError client event for customizing the error message...but I am not seeing any way to determine WHY the file failed to upload. Was it a server issue, was the file too big? Or (like us) was it a file extension that we don't support uploading?
Is there a way to find the actual error message returned on a failure of an upload? This would make the control much more useful than a generic "Oh man, it failed" message.
thanks.
You can return a response from the server if the upload request itself is successful, but the server validation fails. See Sending and receiving metadata.
If the upload fails, you only have access to the raw server response and error code, at best.
I hope this helps.
Tsvetomir Tsonev
the Telerik team
EDIT:
This looks like a false alarm. I noticed in Visual Studio's listing of javascripts being loaded that my kendoui "live" script was being invoked twice. I eliminated the double invocation and now the Upload only calls "save" once.