Export (0) Print
Expand All

Page.MasterPageFile Property

Gets or sets the file name of the master page.

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

public:
virtual property String^ MasterPageFile {
	String^ get ();
	void set (String^ value);
}
/** @property */
public String get_MasterPageFile ()

/** @property */
public void set_MasterPageFile (String value)

public function get MasterPageFile () : String

public function set MasterPageFile (value : String)

Not applicable.

Property Value

The file name of the master page.

Exception typeCondition

InvalidOperationException

The MasterPageFile property is set after the PreInit event is complete.

HttpException

The file specified in the MasterPageFile property does not exist.

- or -

The page does not have a Content control as the top level control.

The MasterPageFile property is the name of the master page file associated with this page. The MasterPageFile property can be set only in the PreInit event; attempting to set the MasterPageFile property after the PreInit event will throw an InvalidOperationException exception. If the MasterPageFile property is not valid, an exception of type HttpException is thrown later in the page life cycle, but no exception is thrown when the property is set in the PreInit event.

Pages that have the MasterPageFile property set are content pages, and therefore can contain only top-level controls that are Content controls.

TopicLocation
How to: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications
How to: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications
How to: Create Content Pages for an ASP.NET Master Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft