0

How to hide new site option in feature is activated event. when feature is deactivated it will visible to users

3
  • You mean hide the option to create new subsite?
    – Mark L
    Commented Apr 21, 2016 at 3:19
  • Which version of SharePoint you are in? Commented Apr 21, 2016 at 3:23
  • 2010 , yes we need to hide new site option when feature activated event receiver
    – kumar
    Commented Apr 21, 2016 at 3:27

1 Answer 1

0

You can add following custom action:

<CustomAction
    Id="HideCreateSiteInSiteActions"
    Location="Microsoft.SharePoint.StandardMenu"
    GroupId="SiteActions"
    Sequence="901"
    Title="Publishing SiteActions Menu Customization"
    ControlAssembly="Your Assembly full name"        ControlClass="your class full name">

And following code in the Class file:

public class YourClassName : WebControl
{
    protected override void OnLoad(EventArgs e)
    {
        var siteActions = ToolBarMenuButton.GetMenuControl(this);
        siteActions.MenuControl.PreRender += (o, args) =>
        {
            var targetMenu = siteActions.GetMenuItem("MenuItem_CreateSite");
            if (targetMenu == null) return;
            siteActions.MenuControl.HiddenMenuItems.Add(targetMenu);
        };
    }        
}

Reference link here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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