@Html. Partial, @Html. Action, @Html. renderpartial, @Html. renderaction in ASP.

Source: Internet
Author: User

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 then callback. Partial and renderpartial directly load the contents of the view file.

3. Html.partial can provide the user control name directly as a parameter, and html.action needs a corresponding action to return Partailresult (that is, Retun Partialview ()) within the action.

4, for a simple user control without any logic, it is recommended to use html.partial; for user controls that need to set some model, Html.action is recommended. Of course, there are model data can also use the Html.partial method, you can see the overloads of the method.

5, the use of html.action has the advantage that can be based on different scenarios to choose a different user control. Like what:
@Html. Action ("Userinfocontrol")
In the corresponding Userinfocontrol this action, when the user is not logged in, you can Retun Partialview ("Logonusercontrol"), after logging in, you can Retun Partialview (" Userinfocontrol ");

~ Don't like to spray oh ~

ASP @Html. Partial, @Html. Action, @Html. renderpartial, @Html. Renderaction

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.