In SharePoint we can Apply Master Pages programmatically using CSOM(Client Object Model). I have a requirement where we are using an EXE file which is build on .Net Client Object Model(CSOM). In this exe file, we wrote code to create sub sites and for that created sub sites we have to apply the master pages.
Here is the sample code for Applying master pages using Client Side Object Model.
Hope this article is Helpful for you.
Here is the sample code for Applying master pages using Client Side Object Model.
public void ChangeGroupMasterPage() { try { Site site = this.Context.Site; this.Context.Load(site); this.Context.ExecuteQuery(); Web web = this.Context.Web; this.Context.Load(web); web.CustomMasterUrl = site.ServerRelativeURL + "/_catalogs/masterpage/custom.master"; //Update the system master. web.MasterUrl = site.ServerRelativeURL + "/_catalogs/masterpage/customSystem.master"; web.Update(); this.Context.ExecuteQuery(); } catch (Exception ex) { //Ex message log } }
Hope this article is Helpful for you.
Apply Master Page using CSOM in SharePoint
Reviewed by Sudheer Gangumolu
on
January 27, 2015
Rating:
I like what you guys are up too. Such intelligent work and reporting!Keep up the excellent works guys I have incorporated.
ReplyDeleteSharePoint Online Training