In ASP. net mvc, @ Html. Partial, @ Html. Action, @ Html. RenderPartial, @ Html. RenderAction,

Source: Internet
Author: User

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 it. While Partial and RenderPartial directly load the View File Content

2. Html. Partial can be directly supplied to the user control name as a parameter, while Html. Action must have a corresponding Action, and PartailResult (retun PartialView () is returned within the Action ()).

3. Html. Partial is recommended for simple user controls without any logic. Html. Action is recommended for user controls that require some Model settings. Of course, the Html. Partial method can be applied to Model data. You can refer to the method for overloading.

4. What is the difference between Html. Partial and Html. Action? The difference is that Html. Partial has only one view, while Html. Action corresponds to an Action in addition to a view. Therefore, Html. Action is more powerful than Html. Partial.

 

How to call this Html. Partial

 // 1. Use the view in the current folder by the view name (if not found, search for the Shared folder)
@Html.Partial( "_test" // Load the corresponding file/Views/Product/_ test. cshtml  // 2. Locate the view based on the application root path // use "/" or "~ The path starting with/"indicates the application root path. @Html.Partial( "~/Views/Product/_test.cshtml" ) @Html.Partial( "/Views/Product/_test2.cshtml" )  // 3. Load view files from other directories // Note: copy the web. config in views to the template directory. Otherwise, the view at "/template/A. cshtml" must be derived from WebViewPage or WebViewPage. <TModel>" @Html.Partial( "/template/A.cshtml" )

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.