In ASP. @html.partial, @Html. Action, @Html. renderpartial, @Html. Renderaction differencesMake a summary of these four differences, clean up the idea, convenient for later use:1. The return value of the method with render is void, output inside the method, and the return value type is mvchtmlstring, so this can only b
reproduced from: "ASP. @Html. @Html. Action @Html. renderpartial @Html. Renderaction differences"Copy it over first.The return value of the method with render is void, output inside the method, and the return value type without render is mvchtmlstring, which is a string.Part
In ASP. net mvc, @ Html. Partial, @ Html. Action, @ Html. RenderPartial, @ Html. RenderAction,
1. View of the Action and RenderAction loading method, perform the order of Controller → Model → View, and then bring the generated page back to the original View before returning
renderaction are often used to display a relatively independent "block", such as a menu or a navigation bar. The results of both outputs are displayed as part of the view that is called.Different points of the two
Renderpatial's data comes from the calling view, and renderpatial comes from itself.
Renderaction will initiate a new request, and renderpatial will not.
How to chooseBased on the 2nd of the differences, because Renderaction invokes a new action method, the action in
1. the return value of the render method is void, which is output within the method. The return value type without the render is mvchtmlstring. Therefore, you can only use the following method:
@ Html. Partial @ {html. renderpartial (...) ;}@ html. action @ {html. renderact
1. The return value of the method with render is void, output inside the method, and without the return value type mvchtmlstring, so use:@Html. Partial corresponds to @{html.renderpartial (...);}@Html. Action corresponds to @{html.renderaction (...);}2, Action, renderaction loading method of the view, the execution of Controller→model→view order, and then the resulting page back to the original view and the
1. The return value of the method with render is void, output inside the method, and the return value type is mvchtmlstring, so this can only be used:@Html. Partial corresponds to @{html.renderpartial (...);}@Html. Action corresponds to @{html.renderaction (...);}2, html.partial can directly provide the user control name as a parameter, and html.action need to have a corresponding action, within the action
Both of them can output a Partial view. The difference is as follows:
1. Partial has a return value (MvcHtmlString); RenderPartial has no return value (Void ).
Definition
1 // PartialExtensions. Partial method (HtmlHelper, String)2 public static MvcHtmlString Partial (3 this HtmlHelper htmlHelper,4 string partialViewName5)67 // RenderPartialExtensions. RenderPartial method (HtmlHelper, String)8 public stati
Both of them can output a Partial view. The difference is as follows:1. Partial has a return value (MvcHtmlString); RenderPartial has no return value (Void ). Definition1 // PartialExtensions. Partial method (HtmlHelper, String)2 public static MvcHtmlString Partial (3 this HtmlHelper htmlHelper,4 string partialViewName5)67 // RenderPartialExtensions. RenderPartial method (HtmlHelper, String)8 public static
① Html. Partial is the extension method of htmlhelper, while HTML. renderpartial is the built-in method of htmlhelper, which has similar functions. However
② Htm. Partial is to directly generate a string for the View content and return it (equivalent to an escape process ).
The HTML.
The Extension Method of HtmlHelper is similar to the RenderPartial function of HtmlHelper,
However, Partial directly generates a string and returns the View content. The RenderPartial method is to directly output it to the current HttpContext. Therefore, they are used differently in the View:
MVC2:
MVC3:@ Html. Partial ("BasicChart ")@{
Both html. renderpartial and HTML. renderactionp are used to embed the MVC user control into the view.
Html. renderpartial is to directly embed the MVC user control into the interface.
Html. renderaction calls the MVC us
Templars-Blue Sword ActionHtml.partial and HTML. RenderPartial usage
Html.partial and HTML. RenderPartial usage
The usage and difference of html.partial and renderpartialHtml.partial and renderpartial are output HTML
Html.partial and HTML. RenderPartial usage
The usage and difference of html.partial and renderpartialHtml.partial and renderpartial are output HTML fragments, the difference isPartial is to directly generate a string of the view content and return (equivalent to an escape process), the
Partial and renderpartial:The two are of the same nature. They only mean to insert one view into each view, but the return value is a little different.An object (mvchtmlstring) returned by partial, returns a string, returns a bunch of HTML, and writes it to the home page.
@ Html. Partial ("viewname ")
Renderpartial returns void, which adds the specified view on t
There are several ways to load a partial view in a view, including:The Partial () Action () renderpartial () renderaction () Renderpage () method.The following are the differences between these methods:Partial and RenderPartial methods1. Razor syntax: @Html. Partial () and @{html.renderpartial ();}2. Difference: Partial can directly output the content, it is insi
output content is a normal UL list. No tree-shaped folding effect. After you have actively set Processoutput=true, all client-side scripts will be output in front of the list CTreeView required.
Here are a few of the related functions to use:
Render,renderpartial no longer introduceProcessoutput ()
The above in the actual operation is still more useful, for example, you do not want to use large-form, you can directly transfer variables to the templa
Asp. Net MVC3.0 Partial RenderPartial Action RenderAction differences and usage,
I do not write many blog posts and have poor professional knowledge. The following are my personal notes. If there is any problem, please take different approaches and provide brick-and-mortar guidance. Thank you!
Differences:
1. The properties of Partial and RenderPartial are basically the same, but a static user control is em
Partial and RenderPartial:Both of the properties are the same, only refers to a view to the inlay in, but the return value is a little differentAn object (mvchtmlstring) that returns a string to return a bunch of HTML, and then writes it to the main page.@Html. Partial ("ViewName")The renderpartial callback is void, and this method adds the specified view to the
Pages in ASP. NET MVC tend to have a lot of reuse where they can be packaged for reuse.Using partial views has the following advantages: 1. You can abbreviate the code. 2. The page code is clearer and better maintained.There are several ways to load a partial view in a view, including: Partial (), renderpartial (), Action (), Renderaction (), Renderpage () methodsI. Partial and renderpartial1.Razor syntax: @Html
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.