Walkthrough: Removing a Button from the Server Ribbon
Applies to: SharePoint Foundation 2010
This topic describes how to remove a button from the Server ribbon in Microsoft SharePoint Foundation.
Prerequisites
SharePoint Foundation 2010
SharePoint development tools in Microsoft Visual Studio 2010
Creating a SharePoint Project
To remove a button, you start by creating an empty SharePoint project.
To create a SharePoint project
Start Visual Studio 2010.
On the File menu, point to New, and then click Project.
In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
Type RemoveARibbonButton as the project name, and then click OK.
In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
Adding a New Feature
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.
To add a new Feature
In Solution Explorer, right-click Features, and then select Add Feature.
Change the Title of the Feature to Remove a Ribbon Button.
In Solution Explorer, right-click Feature1, and then click Rename. Type RemoveARibbonButton as the new name.
In Solution Explorer, right-click the RemoveARibbonButton project, point to Add, and then click New Item.
In the Add New Item dialog box, select the Empty Element template. Type RemoveARibbonButton as the name.
Defining the Custom Action
You remove the ribbon button by using the Location attribute of the CommandUIDefinition element. The default values for ribbon buttons are listed in Default Server Ribbon Customization Locations. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.
To define the custom action
Open the Elements.xml file.
Paste the following XML into the Elements.xml file. This XML removes the Connect to Outlook button on the Library tab in the Connect & Export group for a document library.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="https://schemas.microsoft.com/sharepoint/"> <CustomAction Id="RemoveRibbonButton" Location="CommandUI.Ribbon"> <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location="Ribbon.Library.Actions.ConnectToClient" /> </CommandUIDefinitions> </CommandUIExtension> </CustomAction> </Elements>
Deploying the Customization
Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.
To deploy the customization
Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
Navigate to a document library in your site or subsite.
Click the Library tab, look in the Connect & Export group, and observe the absence of the Connect to Outlook button.