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 Online

The cloud parts are functional components that extend your SharePoint Online environment in Microsoft 365.

Supports Classic and Modern sites for SharePoint Online/Microsoft 365

Small Business Pricing and Discounts

SharePoint

Top SharePoint Online Products

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


Calendar Plus


Carousel


Employee Directory Plus


Org Chart Plus


Simple Search


Tabify


Tree View

 

On-Premises Only

These web parts extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of SharePoint Web Parts.

SharePoint 2016, 2019, 2022 – Classic Pages Only

SharePoint

Top On-Premises Only Products

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


Calendar Plus


Data Viewer


Password Change


Password Expiration


Password Reset

 

Our team of Microsoft 365 Technology Consultants helps you get the most out of your Microsoft technology, we have the best Microsoft 365 talent to streamline your organization.

Consulting to Streamline Your Department

M365 Plus

Managed Services

Microsoft 365

Consulting to Streamline Your Department


Human Resources


Information Technology


Marketing Campaigns


Healthcare


Sales

 

Our Consultants Have What You Need

Federal Contractors