About the ASP. MVC3----@Html. Partial, @Html. Action, @Html. renderpartial, @Html. renderaction

Source: Internet
Author: User
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 return Partailresult (that is, Retun Partialview ()).
3, 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.
4, 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 ");

About ASP. MVC3 [email protected], @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.