Can I return a Json result that contains also a rendered view?
I need it to return the new ID of a submitted form along with its HTML and some other properties.
Also that can be helpful when I need to return two (or more) view results from one action inside a Json object.
Thanks!
You can also render a PartialViewResult to a string, and then pass this string via JSON to your view, rendering it in your page using jQuery.
You can see that in this post: http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/.
I’ve created an extension to make it easier:
In my controller I call it as follows:
Where “this” is the controller in the case, “ProductItemForm” is my view and “model” is my productItem object 🙂
Hope this helps 😉