SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using CSOM and c#, I would like to change the master-page from Seattle to Oslo. Can anybody help me?

share|improve this question
up vote 7 down vote accepted

Use the MasterUrl and CustomMasterUrl properties of Web:

using (var ctx = new ClientContext( url ))
{
    var web = ctx.Web;
    var masterPageUrl = String.Format( "{0}/_catalogs/masterpage/oslo.master", ctx.Web.ServerRelativeUrl );

    web.MasterUrl = masterPageUrl;
    web.CustomMasterUrl = masterPageUrl;
    web.Update();

    ctx.Load( web );
    ctx.ExecuteQuery();
}
share|improve this answer
    
how can i reset all subsites to use same master page? – vignesh Oct 7 '15 at 3:43
1  
The master page will have to be uploaded to every site collection and published. Then go through each site collection with the code in my answer. – wjervis Oct 7 '15 at 4:58
    
sharepoint.stackexchange.com/questions/158944/… can you answer this question which is on the same line? – vignesh Oct 8 '15 at 3:30

Changing Master page is very easy in SharePoint Using CSOM, we can give the Master Page URL in the web masterpage property, for reference u can check this link : http://www.sharepointsol.com/2015/01/apply-master-page-using-csom.html

share|improve this answer
    
is there a way to enforce "reset all subsites to use same master page" using CSOM? – vignesh Oct 7 '15 at 9:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.