Wednesday, 26 October 2016

How to deploy a custom master page from SharePoint farm solution.



Right click on your project > Add New Item > Module

Rename Sample.txt to MyCustomMaster.master

Replace the content of Element.xml with following:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module Name="CustomMasterPages" Url="_catalogs/masterpage" List="116">

    <File  Url="MyCustomMaster.master" Path="CustomMasterPages\MyCustomMaster.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE" >

      <Property Name="UIVersion" Value="15"></Property>
      <Property Name="MasterPageDescription" Value="This is the master page for custom pages." />
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
    </File>
  </Module>
</Elements>


Refer it like this from your pages:

MasterPageFile="/_catalogs/masterpage/MyCustomMaster.master"


No comments:

Post a Comment