Monday, July 23, 2012

sharepoint programmatically change master page


SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
using (SPWeb web = site.OpenWeb())
{
//Logging feature activation status in list
web.AllowUnsafeUpdates = true;
//Changing the master page
web.CustomMasterUrl = "/commerce/Custom/_catalogs/masterpage/Custom.master";
web.MasterUrl = "/commerce/Custom/_catalogs/masterpage/Custom.master";
//Setting the Navigation propertiers for web
web.AllProperties["__IncludeSubSitesInNavigation"] = "False";
web.AllProperties["__IncludePagesInNavigation"] = "True";
web.Update();
}
}
}

No comments:

Post a Comment