user3112115
user3112115

Reputation: 715

ASP.net what is MasterPageFile attribute?

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

ASP.net what means is MasterPageFile attribute?

Upvotes: 4

Views: 5811

Answers (1)

mboldt
mboldt

Reputation: 1835

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.

Upvotes: 6

Related Questions