Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Page Class
Page Properties
 MasterPageFile Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Page..::.MasterPageFile Property

Gets or sets the file name of the master page.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
Public Overridable Property MasterPageFile As String
Visual Basic (Usage)
Dim instance As Page
Dim value As String

value = instance.MasterPageFile

instance.MasterPageFile = value
C#
public virtual string MasterPageFile { get; set; }
Visual C++
public:
virtual property String^ MasterPageFile {
    String^ get ();
    void set (String^ value);
}
JScript
public function get MasterPageFile () : String
public function set MasterPageFile (value : String)
ASP.NET
<asp:Page MasterPageFile="String" />

Property Value

Type: System..::.String
The file name of the master page.
ExceptionCondition
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: Create Content Pages for an ASP.NET Master PageBuilding ASP .NET Web Applications in Visual Studio
How to: Create Content Pages for an ASP.NET Master PageBuilding ASP .NET Web Applications in Visual Studio
How to: Create Content Pages for an ASP.NET Master Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio
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: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications in Visual Studio
How to: Reference ASP.NET Master Page ContentBuilding ASP .NET Web Applications in Visual Studio

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker