MasterPage.MasterPageFile Property
Gets or sets the name of the master page that contains the current content.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.StringThe name of the master page that is the parent of the current master page; otherwise, null, if the current master page has no parent.
| Exception | Condition |
|---|---|
| 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.
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.
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.
Available since 2.0