Page.MasterPageFile 属性

获取或设置母版页的文件名。

命名空间:  System.Web.UI
程序集:  System.Web(在 System.Web.dll 中)

 

C#

public virtual string MasterPageFile { get; set; }

ASP.NET

<asp:Page MasterPageFile="String" />
属性值

类型:System.String

母版页的文件名。

 

异常

异常 条件
InvalidOperationException MasterPageFile 属性在 PreInit 事件完成后进行设置。
HttpException MasterPageFile 属性中指定的文件不存在。 或 页中没有作为顶级控件的 Content 控件。

 

MasterPageFile 属性是与此页关联的母版页文件的名称。MasterPageFile 属性只能在 PreInit 事件中进行设置;尝试在 PreInit 事件后设置 MasterPageFile 属性将引发 InvalidOperationException 异常。如果 MasterPageFile 属性无效,在页生命周期的随后阶段会引发一个 HttpException 类型的异常,但是在 PreInit 事件中设置该属性时不会引发任何异常。

设置了 MasterPageFile 属性的页是内容页,因此只能包含作为 Content 控件的顶级控件。

posted @ 2008-06-29 20:01  superfang  阅读(624)  评论(0编辑  收藏  举报