Hiding a Single Button on Ribbon and Site Actions Menu

 

Run following method in the Page_Load method, you can use delegate control or custom control (.ascx) to implement this.

protected void Page_Load(object sender, EventArgs e)
{
}

Hide a Ribbon
public void HideRibbon()
{
SPRibbon current = SPRibbon.GetCurrent(this
.Page);
if (current != null && !this
.Page.Request.IsAuthenticated)
{
 
current.CommandUIVisible = false
;
}
}


 


Hide a Button on Ribbon

SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
if (ribbon != null)
{
  SPUser currentUser = SPContext.Current.Web.CurrentUser;
  if (currentUser.LoginName.Equals("loginname",StringComparison.InvariantCultureIgnoreCase))
{
ribbon.TrimById("Ribbon.Library.Actions.OpenWithExplorer");
}

 


Hide Status Bar


public void HideStatusBar()
{
string script = "document.onreadystatechange=fnRemoveAllStatus; function fnRemoveAllStatus(){removeAllStatus(true)};"
;
this.Page.ClientScript.RegisterClientScriptBlock(typeof(HideTheRibbon), "statusBarRemover", script, true
);
}


 


Hide Site Actions


public void HideSiteActionsMenu()
{
SiteActions actions = SiteActions.GetCurrent(this
.Page);
if (actions != null && !this
.Page.Request.IsAuthenticated)
{
actions.Visible = false
;
}
}


Ref:
http://howtosharepoint.blogspot.com/2010/06/hide-ribbon-programatically.html
http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=106

Comments

Popular posts from this blog

Referencing Javascript Files with SharePoint 2010 Custom Actions using SciptSrc

Configure Excel Services data access by using external data connection

Uninstall SQL Server Embedded