Page.MasterPageFile Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the virtual path of the master page.
public:
virtual property System::String ^ MasterPageFile { System::String ^ get(); void set(System::String ^ value); };
public virtual string MasterPageFile { get; set; }
member this.MasterPageFile : string with get, set
Public Overridable Property MasterPageFile As String
Property Value
The virtual path of the master page.
Exceptions
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.
Remarks
The MasterPageFile property is a virtual path (from the root of the application) 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.