Geeks With Blogs
Fringe SharePoint Continued

This post is a quick one to post some SharePoint code. This post refers to the post posted by Eric Overfield. Refer to the post to get the full background, but he explains how the OnPreInit event method overrides any MasterPage assignment you might put on your Page Layout. He eludes to the fact that you can use reflector to see that the URL to a master page is overridden. I thought I would post the code. So you understand what is happening in the method and how you can set the master page url. It is a bit unclear in the his post which property needs to be set. It is not the CustomMasterUrl that you have to override. It is the MasterPageFile. In the SharePoint code, the MasterPageFile is overridden by CustomMasterUrl see bellow.

 

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(0x376f6233, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Unexpected,        "PublishingLayoutPage.OnPreInit(): Exception: SPContext.Current is null");
        throw exception;
    }
    SPWeb web = current.Web;
    this.MasterPageFile = web.CustomMasterUrl;
}


 

 This code was extracted from the Microsoft.SharePoint.Publishing.PublishingLayoutPage Class using Reflector.

 

 

 

Posted on Thursday, August 4, 2011 9:56 AM SharePoint | Back to top


Comments on this post: SharePoint 2010: Assign a Unique MasterPage to a Page Layout in a Publishing Portal

# re: SharePoint 2010: Assign a Unique MasterPage to a Page Layout in a Publishing Portal
Requesting Gravatar...
Use HoverBar, users can iPad clamp monitors, desktop or other thickness of aboutone inch of surface. Grip the iPad one end of the spherical bearing is installed,users iPad can be adjusted to any angle.
Left by hoverbar.org on Feb 13, 2012 11:56 PM

Your comment:
 (will show your gravatar)


Copyright © juanlarios | Powered by: GeeksWithBlogs.net