Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Archive for June 30th, 2009

Programmatically Inherit Master Page and CSS in MOSS 2007

Posted by ken zheng on June 30, 2009

The code below is to use the global navigation bar and Inherit site master page from parent of this site

                projectDetailWeb.Navigation.UseShared = true;

                //set masterpage to Inherit site master page from parent of this site
                projectDetailWeb.MasterUrl = projectDetailWeb.ParentWeb.MasterUrl;
                projectDetailWeb.AllProperties["__InheritsMasterUrl"] = "True";

                projectDetailWeb.CustomMasterUrl = projectDetailWeb.ParentWeb.CustomMasterUrl;
                projectDetailWeb.AllProperties["__InheritsCustomMasterUrl"] = "True";

                projectDetailWeb.AlternateCssUrl = projectDetailWeb.ParentWeb.AlternateCssUrl;

                projectDetailWeb.AllProperties["__InheritsAlternateCssUrl"] = "True";

                projectDetailWeb.Update();

Posted in Sharepoint | Tagged: , | 1 Comment »