This documentation is archived and is not being maintained.

MasterPage::MasterPageFile Property

Gets or sets the name of the master page that contains the current content.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public:
property String^ MasterPageFile {
	String^ get ();
	void set (String^ value);
}
<asp:MasterPage MasterPageFile="String" />

Property Value

Type: System::String
The name of the master page that is the parent of the current master page; otherwise, nullptr, if the current master page has no parent.

ExceptionCondition
InvalidOperationException

The MasterPageFile property can only be set in or before the PreInit event.

This section contains three code examples. The first code example demonstrates how to create a nested master page. The second code example demonstrates how to reference the master page that was created in the first code example. The third code example demonstrates how to use a content page to reference the master page that was created in the second code example.

The following code example demonstrates how to create a nested master page and represents the parent master page named ParentMasterPage_1.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to use a nested master page named ChildMasterPage_1 that references the master page that was created in the preceding code example.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to use a content page named ContentPage that references the ChildMasterPage_1 that was created in the preceding code example.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: