Thursday, 28 June 2012

Create custom master page in SharePoint 2007 using Visual Studio

  1. Open Visual Studio 2010 before that please install wspbuilder extension
  2. File->New->Project Select WSPBuilder Project under the WSPBuilder Category
  3. Add new item to the project Select Blank Feature with site scope in the WSPBuilder Category.
  4. Please add the folders and masterpage in the following strucure. 
  • Features
    • SugunthanMasterPageFeature(your feature folder)
      • _catalogs (folder)
        • masterpage(folder)
          • SugunthanMaster.Master(Your master page file)

      5. Remove the Code behind and designer cs files.
      6. Open the element files and change the code like following


<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="SugunthanMasterPageFeature" Url="_catalogs/masterpage" Path="_catalogs/masterpage" RootWebOnly="TRUE">
    <File Url="SugunthanMaster.Master" Path="SugunthanMaster.Master" Type="GhostableInLibrary">
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;"></Property>
      <Property Name="MasterPageDescription" Value="SugunthanMaster.Master" />
    </File>
  </Module>
</Elements>

Note Module Name is your Feature Name.

     7. Open the master page remove all coding
     8. Open any default master page in sharepoint designer and copy the code then paste to your master page
      9. Do the changes and add style what you need.
    10. Compile the code.
    11.  Add and deploy the solution
    12.  Open the Particular website and activate the feature in the site feature collection
    13.  Go to the settings in the look and feel change the master page as yours one.

Happy Coding:)