MVC partial View

Source: Internet
Author: User

Recent projects have been using MVC, often using partial views, and the following is a brief introduction to the partial view.

Using partial views the biggest feeling is that the whole page is grainy, and each large page is made up of these small particles, and these particles can be shared. The volume of our task has been reduced considerably.

Advantages of the partial view:

1. The partial view allows the system to be plug-in.

2. Partial views can also provide an advantage, namely, Division of labor.

3. The partial view also has an advantage in the MVC era, which is simple to implement.

Differences between partial views and views

The view has head, body tag, can define JS, can specify the master page, but when we use the VS right-click to add a partial view, we will see just some basic HTML tags, no head, body. Because we're finally merging these partial views into a single page, we don't define or reference CSS and JS in the partial view. We only need to define or reference in the overall page.

the partial view needs to be noted:

1. If possible, use the motherboard page as much as possible, so that you can control the style of the website well.

2. Use a separate CSS file, separate JS file, try not to define the style in the partial view, but in the overall page.

3. The HTML tags of the partial view should be as few as possible, except for the content to be displayed, no impurities exist. Style css, JS, etc. in the overall page to add.

4. If possible, use Html.partial (partialname) or HTML as much as possible. RenderPartial (Partialname) way, rather than using HTML. Action to act as a partial view, because this method interacts with the controller.

5. The value of the partial view is as model as possible, and if a partial view needs to pass two parameters, I recommend that you split into two partial views.

6. The partial view makes it difficult to style the overall page, so I recommend that you make the page as a whole and then split into different partial views.

7. Excessive partial views increase server latency, so the control of the partial view is appropriate, I recommend control within 10, if the server allows, more is also possible.

8. To pay attention to the name of the label ID of the partial view, it is best to use fixed rules to the naming method to minimize the occurrence of conflicts, after all, the name of the label existence of the program will cause hidden trouble.


MVC partial View

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.