0

I've created a masterpage that displays fine, although if I create a new site, it doesnt inherit. If I go into the masterpage settings then check the box to reset inheritance, it will deploy to all of the existing sites and look right; however, what I need is for it to automatically inherit (all on its own) whenever the site owners create a new site. I cant keep resetting the masterpage to reinherit across the site collection. Any ideas?

Thanks

3

Create an Event Receiver.

In Visual Studio, right click project => Add new item => Event Receiver => Web Events, Handle the following events: A Site is being provisioned.

The following override will be generated and fire on every new site creation. Just insert the code within:

    public override void WebProvisioned(SPWebEventProperties properties)
    {            
        //2)Set master page
        SPWeb web = properties.Web;
        web.CustomMasterUrl = "/_catalogs/masterpage/CustomMasterPage.master";
        web.Update();
        base.WebProvisioned(properties);
    }
  • This answer is right, another way to do it instead of setting the custom master page, is just to enable the OOTB Web publishing feature ("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb") in this event (webProvisioned) in order to inherit the custom parent master page. – agzertuche Jul 14 '14 at 18:07
1

if you don't want to use the webprovisioned method / event receiver then their is one more alternative.

You have to manually update the your master page. check the below blog for more detail.

http://jeffreypaarhuis.com/2011/10/21/your-master-page-automatically-on-newly-created-subsites/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.