Previously, we added a new group to the User-Defined tab and created two buttons. Here we will look at how to add a new button control to this created group (of course, you can add other controls, and the Implementation idea is the same ).
The procedure is as follows:
1. Create a New SharePoint Project
To add a new control to ribbon, you must first create a blank SharePoint project. As follows:
Set this solution as a farm Solution
Add new feature and new blank element respectively in this project, as shown in figure
2. Use the function area XML in the Custom operation to define the function area Custom button item
To open the elements. xml file under customribbonbutton, the content is as follows:
<? XML version = "1.0" encoding = "UTF-8" ?>
< Elements Xmlns = "Http://schemas.microsoft.com/sharepoint" >
< Customaction
ID = "Ribbon. customtabexample. cutomimggroup. addbutton"
Location = "Commandui. Ribbon"
Registrationid = "101"
Registrationtype = "List"
Title = "Add a ribbon button" >
< Commanduiextension >
< Commanduidefinitions >
< Commanduidefinition
Location = "Ribbon. customtabexample. cutomimggroup. Controls. _ Children" >
< Button ID = "Ribbon. customtabexample. cutomimggroup. newimgribbonbutton"
Command = "Customtabexample. newribbonimgbuttoncommand"
Labeltext = "Hello, new IMG group button"
Description = "Says hello, new imggroup button! "
Templatealias = "Cust4"
Sequence = "15" />
</ Commanduidefinition >
</ Commanduidefinitions >
< Commanduihandlers >
< Commanduihandler
Command = "Customtabexample. newribbonimgbuttoncommand"
Commandaction = "Javascript: Alert ('hello, new added IMG button World ');" />
</ Commanduihandlers >
</ Commanduiextension >
</ Customaction >
</ Elements >
The following content is described as follows:
First, we need to use the location determination method described in the previous article to find the location where the button we need to add should be added to ribbon.
In this example, the location is ribbon. customtabexample. cutomimggroup (Format: [ribbon]. [Tab]. [name of the target group]. controls. _ children), so here, location is: Location = "ribbon. customtabexample. cutomimggroup. controls. _ Children"
The ID of the new button becomes ribbon. customtabexample. cutomimggroup. newimgribbonbutton.
3. Deploy custom group items
Press F5. The SharePoint development tool in Visual Studio 2010 will automatically build and deploy functions.
Go to the document library of the website or sub-website.
Click the "my custom tab" tab to view the "Custom group", and then click the newly added buttonr button Hello, new IMG group button. The effect is shown in figure