使用英语阅读

通过


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 属性将引发异常InvalidOperationException。 如果属性 MasterPageFile 无效,则类型 为 的 HttpException 异常将在页面生命周期中稍后引发,但在 事件中 PreInit 设置该属性时不会引发异常。

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

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

另请参阅