Html. Partial and Html. RenderPartial in MVC, html. renderpartial

Source: Internet
Author: User

Html. Partial and Html. RenderPartial in MVC, html. renderpartial

The Partial auxiliary method is used to render some views into strings. Note:You do not need to specify the path and file extension for the view, because the logic for locating some views at run time is the same as that for locating normal views.. For example, the following code renders a partial view named AlbumDisplay. You can use all available view engines to search for them at runtime:

@ Html. Partial ("AlbumDisplay ")

The RenderPartial auxiliary method is very similar to Partial, but RenderPartial does not return a string, but directly writes the response output stream. For this reason, you must put RenderPartial in the code block rather than in the Code expression. To illustrate this, the following two lines of code write the same content to the output stream:

@ {Html. RenderPartial ("AlbumDisplay ");}

@ Html. Partial ("AlbumDisplay ")

Which method should be used? GenerallyPartial is more convenient than RenderPartialSelect Partial. However,RenderPartial has good performanceBecause it is directly written into the response stream, but this performance advantage requires a lot of use (high website traffic or repeated calls in the loop) to see.

-- From ASP. NET MVC4 advanced programming (version 4)

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.