Asp. Net MVC3.0 Partial RenderPartial Action RenderAction differences and usage,

Source: Internet
Author: User

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 embedded in.

2. Partial returns a bunch of html code and writes it directly to the page @ Html. Partial ("ViewName ");

3. RenderPartial Void is returned, and this method will add the specified View @ {Html. RenderPartial ("ViewName");} on the home page ");}

4. The properties of Partial and RenderPartial methods are basically the same, but the Controller is not used to embed a static user control.

5. The RenderAction and Action are a little different. The Controller will be used to return a page.

6. The data of RenderPatial and Partial comes from the called View page. RenderAction and Action initiate a new Request to the Controller, but RenderPatial does not.

Usage:

Method referenced by different Controllers

@ Html. Partial ("~ /Views/Ascx/Head. cshtml ") // user control path
@ {Html. RenderPartial ("~ /Views/Ascx/Head. cshtml ");}
@ Html. Action ("Head", "Ascx") // Ascx controller name, Head user control name
@ {Html. RenderAction ("Head", "Ascx ");}

 

Same controller reference method

@ Html. Partial ("Head") // Head user control name
@ {Html. RenderPartial ("Head ");}
@ Html. Action ("Head") <br/> // Head Method Name
@ {Html. RenderAction ("Head ");}

Both RenderPartial and RenderAction must be written in.

 

Public ActionResult Head ()
{
ViewBag. Test = "(Home) call ";
Return PartialView ();
}

 

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.