4
Reply

How to change the master page from a winform?

Nelson

Nelson

Nov 9 2009 6:13 PM
4.6k
Hi there,

I am trying to change the master page of a webapp in SS I tried this code:

        public void mSetMasterPage(string sUrlSite, string sWebName)
        {
            using (SPSite oSiteCollection = new SPSite(sUrlSite))
            {
                SPWeb myWebSite = oSiteCollection.OpenWeb(sWebName);
                myWebSite.MasterUrl = "/_layouts/BlackBand.Master";
                myWebSite.CustomMasterUrl = "/_layouts/BlackBand.Master";
                myWebSite.Update();
            }
        }

And in theory this works, but when I open the webapp it only says "Error" and I supose that I am missingo something, but I do not know what, could anyone give me a hand???

Thank you very much for any answer,

Nelson

Answers (4)