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;
    }
}

 

注意最后一句:this.MasterPageFile = web.CustomMasterUrl;

由此可见,PublishingLayoutPage自动获取当前SPContent.Current.Web对象的CustomMasterUrl属性。而WebPartPage则需明确指定应用哪一种master page.

 

 

你可能感兴趣的:(PublishingLayoutPage 和 WebPartPage)