0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
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
I am passing an enumerable of concrete entities instead of a viewmodel. Maybe i have my exceptions turned off. Will investigate. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.