Gets or sets the file name of the master page.
Public Overridable Property MasterPageFile As String
Dim instance As Page Dim value As String value = instance.MasterPageFile instance.MasterPageFile = value
public virtual string MasterPageFile { get; set; }
public: virtual property String^ MasterPageFile { String^ get (); void set (String^ value); }
public function get MasterPageFile () : String public function set MasterPageFile (value : String)
<asp:Page MasterPageFile="String" />
The MasterPageFile property is set after the PreInit event is complete.
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.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98