asp.net.ph

Page.MasterPageFile Property

System.Web.UI Namespace   Page Class


.NET Framework version 2.0

Sets or retrieves the file name of the master page.

Syntax


Inline <%@ Page masterpagefile = strMasterFileName ... %>
Script [ string strMasterFileName = ] Page.MasterPageFile

Property Value


strMasterFileName The file name of the master page.

The property is read/write with no default value.

Exceptions


Exception Type Condition
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.

Remarks

The MasterPageFile property is the name of the master page file associated with a content page.

The MasterPageFile property can be set declaratively using the @ Page directive.

<%@ Page Language="C#" MasterPageFile="~/pages/Master1.master" Title="Content Page" %>
  C# VB

The MasterPageFile property can be set programmatically only in the PreInit event. Attempting to set the MasterPageFile property after the PreInit event will throw an InvalidOperationException exception.

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

See Also

Page Members   MasterPage Class Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph