views:

35

answers:

1

I am retrieving a partial view with Ajax that is a form that can be submitted. If the form is submitted and ModelState is not valid I return the view and hookup the buttons again for the form. With that I get the validation error messages which works quite nice. But when ModelState is valid I want to return a different partial view that I can attach to a table with the saved information.

My problem is I am not sure how my callback can distinguish between the partial views that is returned, I could look for the starting tags of the html that is returned, but I was wondering if there could be a better way?

+1  A: 

With your partial view you can pass a hidden field with value that describes what view is returned. Then parse the returned html with jQuery and get the value of the hidden field.

Branislav Abadjimarinov
thats a good solution. It would've been nice to evaluate the returned type data. then i could say if json then to this else just insert html there.
adriaanp
Yes, you could just return JSON result with two params - the name of the view as first param and a html string as second. Maybe this is even more clean resolution than parsing the returned html.
Branislav Abadjimarinov