views:

22

answers:

1

I have an Ajax Form that looks like this:

<% using (Ajax.BeginForm("Update", new AjaxOptions
   { UpdateTargetId = "message", InsertionMode = InsertionMode.Replace,
     OnSuccess = "success", OnFailure = "error" })) { %>

I can get "error" to run on a failure but i would like to alert the error message. How can i get this information?

Thanks, Kohan.

+1  A: 

I'm assuming you're returning a partialview in the method Update...

I think one of the simplest options would be to render the errors in the partial view you're returning. This way everything happens on the server and you don't have to handle the error display in two places.

samy
Yes, i am returning a partialView, I am also getting it to fail (for testing purposes) by passing in the wrong viewmodel. It does not seem to break when debugging, is the server away of this error before it gets to the view?
Kohan
if you pass a wrong model to a partialview, you _should_ break. Are you sure you're not passing a inherited class of the model you're supposed to use? I think you should perhaps add information regarding the problem, because i'm not sure i've understood it clearly from what you say
samy
I am passing an enumerable of concrete entities instead of a viewmodel. Maybe i have my exceptions turned off. Will investigate. Thanks.
Kohan