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

[Solved] Save action called twice and custom error msgs?

10 Answers 185 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 19 May 2011, 03:59 PM

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

Sort by
0
T. Tsonev
Telerik team
answered on 20 May 2011, 08:46 AM
Hello Christian,

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.

Best Regards,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Samir
Top achievements
Rank 1
answered on 17 Jun 2011, 07:21 AM
Hi,

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,
0
Richard
Top achievements
Rank 1
answered on 21 Jul 2011, 02:49 PM
Hi,

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.
0
T. Tsonev
Telerik team
answered on 22 Jul 2011, 02:47 PM
Hi,

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,

Tsvetomir Tsonev
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!

0
Frank
Top achievements
Rank 1
answered on 13 Sep 2011, 05:15 PM
There is currently movement in #6593 and the fix is slated for jQuery 1.7. How long after the release will there be an updated Telerik Extensions for ASP.NET MVC that supports jQuery 1.7?
0
T. Tsonev
Telerik team
answered on 14 Sep 2011, 09:56 AM
Hello Frank,

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

Regards,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Raj
Top achievements
Rank 1
answered on 10 Jan 2012, 08:15 PM
Hi

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
0
Jay
Top achievements
Rank 1
answered on 24 Jan 2012, 08:13 PM

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.
0
T. Tsonev
Telerik team
answered on 25 Jan 2012, 08:18 AM
Hi,

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.

Greetings,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Boris
Top achievements
Rank 1
answered on 22 Sep 2012, 03:16 PM
I'm getting the double save using the KendoUI Upload, both with jQuery 1.7.2 and 1.8.2, so apparently nothing has actually been fixed yet?

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.
Tags
Upload
Asked by
Christian
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Samir
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Frank
Top achievements
Rank 1
Raj
Top achievements
Rank 1
Jay
Top achievements
Rank 1
Boris
Top achievements
Rank 1
Share this question
or