Ads

Monday, 25 March 2013

Creating a custom Master page in SharePoint 2010 using Visual Studio 2010

Lets create a custom master page in SharePoint 2010 using Visual Studio 2010.
Steps Involved:
  • Open Visual Studio 2010.
  • Go to File => New => Project.
  • Select Empty SharePoint Project from the installed template SharePoint 2010.

     
  • Enter the Name.
  • Click Ok.
  • Enter the local site that you want to use it for debugging.
  • Select "Deploy as a sandbox solution".
  • Click Finish.
  • Right click on the solution and click on "Add a new item".
  • Select the Module template from the installed templates.

     
  • Enter the name and click ok.
  • Rename the Sample.txt to Sample.master.
  • Replace the code with the following code snippet.

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="Module" List="116" Url="_catalogs/masterpage">
        <File Path="Module\Sample.master" Url="Module/Sample.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="false" />
      </Module>
    </
    Elements>
     
  • Go to the SharePoint Designer.
  • Open some existing site in the SharePoint Designer 2010.
  • Go to Navigation => Site Objects =>Master Pages.
  • Make a copy of v4.master.
  • Do some modifications in the copy of v4.master and copy the code.
  • Paste the code in the Sample.master.
Publish the master page:
  • Go to Site Actions => Site Settings =>Galleries => Master pages and page layouts => Module =>Sample.master.
  • Go to the ECB menu, click on "Check in". 
  • Go to the ECB menu, click on "Publish a major version".  
  • Go to the ECB menu, click on "Approve/Reject".  
  • Select the "Approved" option. Click on Ok
Change the master page of the SharePoint site with the custom master page
  • Go to the SharePoint Site => Site Actions => Site Settings => Site Collection Administration => Site Collection Features.
  • Activate the following feature "SharePoint Server Publishing Infrastructure".  
  • Go to Site Actions => Site Settings =>Site Actions => Manage Site Features.
  • Activate the following feature "SharePoint Server Publishing".  
  • Go to Site Actions => Site Settings => Look and feel => Master Page.
  • Select the custom master page as shown in the following.
  • Click Ok.

Refer: c-sharpcorner

No comments:

Post a Comment

Ads