PublishingLayoutPage 和 WebPartPage
类继承关系:
System.Web.UI.Page
Microsoft.SharePoint.WebPartPages.WebPartPage
Microsoft.SharePoint.Publishing.PublishingCachablePage
Microsoft.SharePoint.Publishing.PublishingLayoutPage
用Relector打开Microsoft.SharePoint.Publishing.dll, PublishingLayoutPage的定义如下:
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class PublishingLayoutPage : PublishingCachablePage
{
// Methods
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
SPContext current = SPContext.Current;
if (current == null)
{
SPException exception = new SPException(Resources.GetString("ErrorInvalidSPContextCurrent"));
ULS.SendTraceTag(ULSTagID.tag_7ob3, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Unexpected, "PublishingLayoutPage.OnPreInit(): Exception: SPContext.Current is null");
throw exception;
}
SPWeb web = current.Web;
this.MasterPageFile = web.CustomMasterUrl;
}
}
public class PublishingLayoutPage : PublishingCachablePage
{
// Methods
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
SPContext current = SPContext.Current;
if (current == null)
{
SPException exception = new SPException(Resources.GetString("ErrorInvalidSPContextCurrent"));
ULS.SendTraceTag(ULSTagID.tag_7ob3, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Unexpected, "PublishingLayoutPage.OnPreInit(): Exception: SPContext.Current is null");
throw exception;
}
SPWeb web = current.Web;
this.MasterPageFile = web.CustomMasterUrl;
}
}
注意最后一句:this.MasterPageFile = web.CustomMasterUrl;
由此可见,PublishingLayoutPage自动获取当前SPContent.Current.Web对象的CustomMasterUrl属性。而WebPartPage则需明确指定应用哪一种master page.
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利
This posting is provided "AS IS" with no warranties, and confers no rights.
This posting is provided "AS IS" with no warranties, and confers no rights.