Monday, June 9, 2014

Master Page Deployment using Visual Studio as a Feature


DEVELOPING AND DEPLOYING MASTER PAGE

Open Visual Studio 2010 -> C# -> SharePoint 2010 -> SharePoint 2010 Empty Project -> <Project Name> eg., MSODBSolution -> Site URL -> Sandbox Solution

Now Right-click on Project <MSODBSolution> and select New Item -> Select Module from the existing SharePoint Site templates -> Give module a name eg., MSODBModule

You will see the Features folder is updated and You will also find 2 files in Module template added to Solution Explorer. They are: Elements.xml and Sample.txt.

o    Modify Sample.txt to a master page eg., MSODB.master and copy the code from v4.master and paste it in this MSODB.master file.

o    Update the Elements.xml file and make sure that the URLs, Paths and List property values are updated as follows:
                        <Module Name="MSODBModule" List ="116" RootWebOnly="TRUE" Url="_catalogs/Masterpage">
                                                <File Path="MSODBModule\MSODBMain.master" Url="MSODBModule/MSODBMain.master" />
                                </Module>

Now open Feature1 and make sure that the scope was set to web (will be based on your requirement) and also make sure that the contents from Items in the Solution are moved to Items in the Feature section


THATS IT.... BUILD (CTRL + SHIFT + B) & DEPLOY (CTRL + F5)


You can now see a New Solution got created under Solutions pages in your deployed website -> You can check this by going to Site Actions -> Site Settings -> Solutions (Under Gallery section)

For Applying this master page, you now need to go to Site Actions -> Site Settings -> Master Page (Under Look and Feel section) and then select the newly deployed custom Master page.

You can modify the code in the master page as required.

No comments:

Post a Comment

Please Leave Your Comments Here On This Post.....

Followers