Programmatically Customize The Ribbon

The below mentioned codes explains the methods of customizing the ribbon in SharePoint, programmatically.
 
Hide a Ribbon
  1. public void HideRibbon()  
  2. {  
  3. SPRibbon spRibbon = SPRibbon.GetCurrent(this.Page);  
  4. if (SPRibbon != null && !this.Page.Request.IsAuthenticated)  
  5. {  
  6. SPRibbon.CommandUIVisible = false;  
  7. }  
  8. }  
Hide a Ribbon Group
  1. SPRibbon spRibbon = SPRibbon.GetCurrent(this.Page);  
  2. if (spRibbon != null)  
  3. {  
  4. spRibbon.TrimById(“RibbonGroupId”);  
  5. }  
Hide a single ribbon button
  1. public void HideRibbonItem()  
  2. {  
  3.   
  4. SPRibbon spRibbon = SPRibbon.GetCurrent(this);  
  5. spRibbon.TrimById("Ribbon.ListItem.New.NewFolder");  
  6. }  
  7.    
Ebook Download
View all
Learn
View all