SharePoint 2010 ribbon customization : how to hide Ribbon programatically

programatically hide a Ribbon

 
1
2
3
4
5
6
7
8
9
public void HideRibbon()
{
  SPRibbon current = SPRibbon.GetCurrent(this.Page);
  
  if (current != null && !this.Page.Request.IsAuthenticated)
  {
    current.CommandUIVisible = false;
  }
}

programatically hide a single ribbon button

 
1
2
3
4
5
6
public void HideRibbonItem()
{
 //if this is a System.Web.UI.Page
 SPRibbon ribbon = SPRibbon.GetCurrent(this);
 ribbon.TrimById("Ribbon.ListItem.New.NewFolder");
}

programatically hide the status bar

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

programatically hide the SiteActions Menu

 
1
2
3
4
5
6
7
8
9
public void HideSiteActionsMenu()
{
  SiteActions actions = SiteActions.GetCurrent(this.Page);
  
  if (actions != null && !this.Page.Request.IsAuthenticated)
  {
       actions.Visible = false;
  }
}

Ref: http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=106

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: