Click here to Skip to main content
15,909,466 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2013
Tip/Trick

Creating Custom Master Page for Hosted Apps

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Sep 2014CPOL1 min read 13.8K  
Creating Custom Master Page for Hosted Apps

Introduction

When you are building SharePoint 2013 apps, the Chrome control is used to make sure your app is in sync with the Host Web. However, there may be some situations where you would want to create your own master page and use it within your app. I have detailed below the step by step approach to achieve this requirement.

Step 1

Create your custom master page. You can start with the minimal.master page and customize it as per your requirements.

  • You can take the minimal.master page either from an on Premises SharePoint Server or from SharePoint Online. If you are using the master page from SharePoint Online, make sure you change the assembly version number to 15 instead of 16 so that the master page can be used within on Premises as well as SharePoint Online.
  • You will have to change the doc type to HTML if you are building a master page with Responsive UI.

Step 2

Create a Module in your project to add the master page that you just created above.

  • Add your custom master page to this module.
  • You will need to modify the elements.xml file so that your master page will go to the master page gallery of your app as below:
XML
<File Path="ModuleName\CustomMasterPageName.master" 
Url="_catalogs/masterpage/ CustomMasterPageName.master" 
Type="GhostableInLibrary"></File>
  • Replace ModuleName with your module name.
  • Replace CustomMasterPageName with your master page name.
  • The above change will deploy the master page into the master page catalog document library of your app.
  • GhostableInLibrary will make sure the document is placed within the document library.

Step 3

Change the master page name for your App Pages as below:

XML
MasterPageFile="~site/_catalogs/masterpage/ CustomMasterPageName.master"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --