ASP.net what is MasterPageFile attribute?

时间:2015-06-26 09:35:26

标签: asp.net-mvc

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ModelCentral.AbModel>" %>

ASP.net what means is MasterPageFile attribute?

1 个答案:

答案 0 :(得分:0)

Each .aspx page can reference a master page. The master page can define the general layout for that specific page (obviously you can use a masterpage for multiple pages).

Imagine you have a standard website with a main menu, a content area and a footer. The master page would include the main menu and the footer since they usually don't change. Moreover the master page contains a <asp:ContentPlaceholder> which will later be populated by the content of your .aspx-page.

A master page can contain multiple <asp:ContentPlaceholder>. In your .aspx-page you can use the <asp:Content> control to populate a <asp:ContentPlaceholder> with your content. Note that you have to match the ContentPlaceHolderID of your <asp:Content> with the correct ID of your `.

Read this article for more information on the subject.