SharePoint 2010 Cookbook: How to Add or Remove a Custom Button on the Ribbon

SharePoint 2010 contains numerous improvements in the user interface and has been built so that it can be extended even further.  By now, I’d guess that most of you have seen the Ribbon in SharePoint 2010, and many of you have probably even tried actions such as adding a button to the Ribbon.  As you’ve probably learned, adding a button is quite an easy and intuitive task, but trust me: performing some of the more advanced contextual and dynamic customizations to the Ribbon can really make you sweat!

The Ribbon is a great new feature which was introduced in SharePoint 2010.  In this article, we will take a look at how to add or remove custom buttons on the Ribbon in SharePoint 2010.

Challenge:

How do I add or remove a custom button on the new SharePoint 2010 Ribbon?

Solution:

Create a Custom Button on the SharePoint 2010 Ribbon

Create Feature Elements File

OK, let’s take a loot at  the code which follows.  What we have here is my Element.xml feature.  Please pay special attention to the ID Group of my extension (red rectangle):

Add or Remove the Ribbon in SharePoint 2010

 

The schema here is basically: Ribbon.[Tab].[Group].Controls._children

And here is the resulting Ribbon group displayed in the UI:

Add or Remove the Ribbon in SharePoint 2010

 

Remove a Custom Button from the SharePoint 2010 Ribbon

At times, you may need to remove some buttons, tabs, or groups from the Ribbon, or otherwise customize the Ribbon to suit  your needs.  Below, what we want to do is remove the custom button from the Ribbon.  This is easily accomplished  adding the following code to Page_Load:

Add or Remove the Ribbon in SharePoint 2010

Note: You will get some squiggly lines underneath SPRibbon. Don’t worry about that, but you will need to add the “using” statement shown below:

Add or Remove the Ribbon in SharePoint 2010

When this code runs, the custom button will be removed from your Ribbon.

 

See Also:

Notes:

See the attachment for the source code and script of this example.


SharePoint

Applications

SharePoint apps are stand-alone applications that perform specific tasks on a SharePoint site. Apps can perform functions such as managing a discussion board or knowledge base, performing project management or time tracking tasks, or doing other workflow operations.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


SharePoint

Web Parts

Extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of Web Parts. Web Parts are the building blocks of pages on a SharePoint site that can be used to customize the user interface and content of a site page. 

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Essentials


Essentials Plus


Bamboo Premier


Project Management Suite


Knowledge Management Suite


External User Manager


Office 365

Cloud Parts

Cloud Parts are functional components that extend your SharePoint environment whether it’s hosted, on-premises, or part of Microsoft Office 365. More than mere ports of existing software to the cloud, our Cloud Parts have been built from the ground up to take advantage of the best that the cloud has to offer.

SharePoint

Product Suites

Experience greater power and savings by bundling our SharePoint apps and web parts.


Cloud Parts Suite for O365/SP Onl.


Featured Services

SharePoint Health Check

A SharePoint Health Check will identify the causes of issues and risks associated with your specific environment, and is custom tailored to provide you with the best recommendations to optimize your SharePoint environment.

SQL Health Check

Document recommendations relating to performance, stability, availability, or a specific focus you request of your SQL Server database instances.

My SharePointXperts

The truth is that each SharePoint skill may not be a full time job for many organizations, and it is nearly impossible for one person to do everything you need – so augment your team with SharePointXperts; providing the skill sets you need when you need them!