ASP. NET mvc3 layout page and distribution page call method Overview

Source: Internet
Author: User

I am not using ASP. NET mvc3 for a long time and have insufficient experience. Therefore, please note the mistakes.

 

Mvc3 is also a web development framework. As a web development platform, it will inevitably involve the call relationship between parent pages and child pages. What are the methods in mvc3?

Based on your current situation, there are two ways to choose from:

 

1. similar to ASP. the masterpage method that appears in net 2.0, that is, add: renderbody () call to the parent page, and add a reference to the parent page in the Child page: Layout = .... If this method is used, the browser must start from the Child page, so that the child page content will be merged to the renderbody () function of the parent page during the call. Otherwise, the system will prompt an error: the file cannot be directly requested "~ /Views/home/*****. cshtml ", because it calls the" renderbody "method.

 

2. remove the reference of the Child page to the parent page: Layout = ..., remove the call to the renderbody () function on the parent page, and use the command @ HTML to call the subpage. partial ("******"). Interestingly, if the called Child page references another parent page in method 1, it is interesting to add a child page and another parent page. This method seems to be more flexible than method 1, so that a single subpage can be referenced by multiple parents. This method is more like a weak type reference, method 1 is like a strongly typed reference.

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.