How to hide new site option in feature is activated event. when feature is deactivated it will visible to users
-
You mean hide the option to create new subsite?– Mark LCommented Apr 21, 2016 at 3:19
-
Which version of SharePoint you are in?– Rajesh SitaramanCommented Apr 21, 2016 at 3:23
-
2010 , yes we need to hide new site option when feature activated event receiver– kumarCommented Apr 21, 2016 at 3:27
Add a comment
|
1 Answer
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);
};
}
}