Tuesday, July 14, 2009

Adding and Removing a button to the Ribbon ( SharePoint 2010 )

*** Please view the disclaimer before you proceed ***

Scenario: Adding and Removing a button on the Ribbon. You can define the location on the Ribbon where you want the button to appear. Follow the below method to add a new button / remove the button to the Library tab in the Actions group for a document library.


    1. Create a folder under 14 hive\Template\Features (SharePoint 2010 will have 14 hive similar to that of 12 in WSS / MOSS 2007) RibbonButton
    2. As seen in the previous post create the feature.xml
    3. Create a blank xml file, manifest.xml and add the below content (Adding Button) to it and Save it.
    4. Deploy the customization using Windows PowerShell as shown in my previous blog.
    5. Test it by navigating to the document library in your site / sub site and clicking on the library tab > Actions group > New Button button.
    6. To remove the button replace the content in the manifest.xml with the Removing Button content mentioned below.

Adding Button:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="Ribbon.Library.Actions.AddAButton"
Title="Add a Ribbon Button">
<Button Id="Ribbon.Library.Actions.NewRibbonButton" Command="NewRibbonButtonCommand"
LabelText="New Button"
TemplateAlias="o2" />
CommandScript="javascript:alert('This is a new button!');" />

// Image16by16 and Image32by32 are part of SharePoint 2010

Removing Button:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<HideCustomAction Id="RemoveRibbonButton"

Technorati Tags: ,

No comments: