The distributed view Partialview is generally functionally independent, and a view snippet similar to a user control can be referenced by multiple views, as follows.
1,html.partial method and Html.renderpartial method
Static class System.Web.Mvc.Html.PartialExtensions, using the extension method, expands the System.Web.Mvc.HtmlHelper, So with the Html.partial method, the method returns a value of Mvchtmlstring
The static class System.Web.Mvc.Html.RenderPartialExtensions, using the extension method, expands the System.Web.Mvc.HtmlHelper, and therefore has the Html.renderpartial method, Method has no return value (void)
All two of the above methods load partial views, but they are not used the same way
Html.partial returns mvchtmlstring, so you can call it in the form of an razor expression
@Html. Partial ("ViewName")
Html.renderpartial does not have a return value, so it is called as an embedded snippet and cannot be used with a razor expression
@{ html.renderpartial ("ViewName");
The above two methods, instead of invoking the Controller's action, are loaded directly based on the specified partial view name.
The default search path for the distribution view is/views/the current controller and/views/shared folder.
2,html.action method and Html.renderaction method
System.Web.Mvc.Html.ChildActionExtensions, extending the System.Web.Mvc.HtmlHelper with the extension method, thus having the action and Renderaction methods,
The Html.action method returns mvchtmlstring, so you can invoke it using the razor expression
@Html. Action ("actionName","childcontrollername")
Html.renderaction does not have a return value (void), so it needs to be put in a code snippet
@{html.renderaction ("actionname","childcontrollername ");}
The above two methods require a mate controller and method (Action)
method returns the Partialviewresult instance (the Controller.partialview () method returns this instance)
These two methods can be used when the calling procedure contains business processing logic.
Html.partial method and Html.renderpartial method