ASP.NET MVC - Combine Json result with ViewResult -


Can I return a JS results that includes a render view?

I need to return it to me

This can also be helpful when I need to return two (or more) visual results from a verb inside the Jason object.

Thank you!

You can also render a partial ViewResult for a string, and then pass this string

You can see in this post.

I have created an extension to make it easier:

Public Stratic Class MvcHelpers {public static string RenderPartialView (this controller controller, string viewname, object model) {if (string. IsNullOrEmptE (viewName)) viewName = Controller. Controller Consort. RouteData.GetRequiredString ("Action"); Controller ViewData Model = model; See {ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView (Controller Controller Contains, Viewing Name) using (Var sw = new stringwriter ()); Var viewContext = New ViewContext (Controller Controller Contains, Visual Protection, View, Controller Viewdata, Controller.Tempadata, Self); Scene View. Render (VisualText, SG); Return sw.getStringBuilder (). ToString (); }}}

In my controller, I call it as follows:

  const string msg = "items updated successfully!"; New Jason Result {data = new {success = true, message = message, see = see it RiderPartialAlview ("Product Itamform", Model)}, Jason Efficient Behavior = JasonEurfest Behavior Elove gate};  

Where "this" is the controller in this case, "ProductItemForm" is my view and "model" is my product item object :)

Hope this helps Does;)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -