Here is a simple small code snippet.
Have Fun.
Have Fun.
public void ApplyCustomBranding(string MasterPageUrlPath, SPWeb site)
{
if(site == null)
{
site = SPContext.Current.Site.RootWeb;
}
if(string.IsNullOrEmpty(MasterPageUrlPath))
{
MasterPageUrlPath = site.ServerRelativeUrl;
if(!MasterPageUrlPath.EndsWith(@"/"))
{
MasterPageUrlPath += @"/";
}
MasterPageUrlPath += @"_catalogs/masterpage/mynew.master";
}
site.MasterUrl = MasterPageUrlPath;
site.Update();
foreach(SPWeb child in site.Webs)
{
ApplyCustomBranding(MasterPageUrlPath, child);
}
}
Comments