locked
Not able to set a master page to page layout RRS feed

  • Question

  • I have 2 master pages and i need to attach 1 master page to specific page layout.

    I assigned the MasterPageFile tag of page layout to my master page as shown below : 

    <%@ Page language="C#" MasterPageFile="_catalogs/masterpage/MyFolder/MyNew.master"  

    But when i tried to create a new page based on this modified page layout it gives me below error :

    System.IO.FileNotFoundException: The file

    /_catalogs/masterpage/MyFolder/_catalogs/masterpage/MyFolder/MyNew.master

    does not exist.

     For below tag values :

    <%@ Page language="C#" MasterPageFile="MyNew.master"  

    it gives me below error :

    System.IO.FileNotFoundException: The file

    /_catalogs/masterpage/MyFolder/MyNew.master

    does not exist.

     Kindly let me know if i am missing anything.

    Tuesday, May 3, 2011 2:31 PM

Answers

  • Adding below masterpagefile attribute in designer changes the inherited class of the page layout

     

     

    MasterPageFile=../MyFolder/MyNew.master

    It becomes Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

    Instead of Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"

     

    So along with masterpagefile attribute also change the inherited class to

    "Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

    Making this change resolved my problem. Now the master page which is set to my page layout is getting applied to it instead of the site master page.

    But only 1 drawback is that, the page created using this modified page layout cannot be edited and saved later.

    Not sure if this can be handled.

    Any help is appreciated.

    Thanks.

    • Marked as answer by Kelkars Thursday, August 25, 2011 11:54 AM
    Wednesday, May 4, 2011 10:01 AM

All replies

  • I have done the same thing and the only differences I can see is here:

    MasterPageFile="_catalogs/masterpage/MyFolder/MyNew.master"  

    Add a "/" at the beginning so it's: MasterPageFile="/_catalogs/masterpage/MyFolder/MyNew.master" 

    Also, make sure you have published the master

    Let us know if any of that helps or if you get the same errors

    Tuesday, May 3, 2011 4:51 PM
  • Thanks for your reply.

    After adding a  "/" at the beginning, the error is gone.

    But when i create a page using the modified page layout, it  doesnt apply the master page required. ie. MyNew.master instead the one which is set as the Site master page under the Look and feel setion of site settings.

    I tried the below way but still it didnt work.

    MasterPageFile=../MyFolder/MyNew.master

     

    Please let me know if anything else needs to be done.

    Wednesday, May 4, 2011 6:05 AM
  • Master page which is set from Look and Feel section of Site Settings overrides master page from page layout, this is default behaviour of SharePoint.
    w: http://www.worldofsharepoint.com | t: @sharesandip
    Wednesday, May 4, 2011 9:07 AM
  • Adding below masterpagefile attribute in designer changes the inherited class of the page layout

     

     

    MasterPageFile=../MyFolder/MyNew.master

    It becomes Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

    Instead of Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"

     

    So along with masterpagefile attribute also change the inherited class to

    "Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

    Making this change resolved my problem. Now the master page which is set to my page layout is getting applied to it instead of the site master page.

    But only 1 drawback is that, the page created using this modified page layout cannot be edited and saved later.

    Not sure if this can be handled.

    Any help is appreciated.

    Thanks.

    • Marked as answer by Kelkars Thursday, August 25, 2011 11:54 AM
    Wednesday, May 4, 2011 10:01 AM