ASP. NET MVC3 Chew slowly --- (2) template page, asp. netmvc3
This section demonstrates how to use the template page in MVC3. In the traditional webform design mode, we use masterpage as the template page. In the MVC3 razor view design, we use another method as the template page.
Create an MVC3 project. In solution resource management, we can see that there is a Shared folder under the VIEWS folder. There is a _ Layout. cshtml page in the Shared folder. This is the default template page in the project. For example, 1. When creating a content page, the content page is also called a view layout page in MVC3. You can right-click the view folder, add the content page by adding a view, and select the corresponding template. The following is the page on which ViewPageOne. cshtml uses the template page. The code is automatically generated on the page. To specify the template page, and use Layout to specify the specific template page. If the content page does not contain the Layout attribute, the default template page [html] @ {ViewBag. Title = "ViewPageOne"; Layout = "~ /Views/Shared/_ Layout. cshtml ";}< h2> ViewPageOne