Page.MasterPageFile 属性

定义

获取或设置母版页的虚拟路径。

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

属性值

母版页面的虚拟路径。

例外

MasterPageFile 属性在 PreInit 事件完成后进行设置。

MasterPageFile 属性中指定的文件不存在。

- 或 -

页中没有作为顶级控件的 Content 控件。

注解

属性 MasterPageFile 是 (与此页面关联的母版页文件的应用程序的根目录) 的虚拟路径。 MasterPageFile只能在 事件中PreInit设置 属性;尝试在事件后PreInit设置 MasterPageFile 属性将引发异常InvalidOperationExceptionMasterPageFile如果 属性无效,则类型为 HttpException 的异常将在页面生命周期的稍后引发,但在 事件中PreInit设置属性时不会引发异常。

具有 MasterPageFile 属性集的页面是内容页,因此只能包含属于 Content 控件的顶级控件。

适用于

另请参阅