After adding and deleting ribbon, let's see how to change (replace) a control in ribbon. Here, we will continue with the previous project and prepare to replace the button in the example with another Custom button.
The procedure is as follows:
1. Use the SharePoint project created earlier
Add a new blank element in this project, as shown in figure
Ii. define the content of this element to implement the replacement function
To open the elements. xml file under replaceribbonbutton, the content is as follows:
<? XML version = "1.0" encoding = "UTF-8" ?>
< Elements Xmlns = "Http://schemas.microsoft.com/sharepoint" >
< Customaction ID = "Ribbon. customtabexample. cutomimggroup. replacementbutton"
Location = "Commandui. Ribbon"
Registrationid = "101"
Registrationtype = "List"
Title = "Replace a ribbon button" >
< Commanduiextension >
< Commanduidefinitions >
< Commanduidefinition
Location = "Ribbon. customtabexample. cutomimggroup. customimggroupgoodbye" >
< Button
ID = "Ribbon. customtabexample. cutomimggroup. replacedbutton"
Command = "Customtabexample. replacementbuttoncommand"
Labeltext = "Replace, IMG button world"
Description = "Replaced, IMG button world! "
Templatealias = "Cust6"
Sequence = "35" />
</ Commanduidefinition >
</ Commanduidefinitions >
< Commanduihandlers >
< Commanduihandler
Command = "Customtabexample. replacementbuttoncommand"
Commandaction = "Javascript: Alert ('this button has been replaced .');" />
</ Commanduihandlers >
</ Commanduiextension >
</ Customaction >
</ Elements >
In this example, we confirm that the button to be replaced is at ribbon. customtabexample. cutomimggroup. customimggroupgoodbye (Format: [ribbon]. [Tab]. [name of the target group]. [name of the target control]), so here, location is: Location = "ribbon. customtabexample. cutomimggroup. customimggroupgoodbye"
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. View the result as shown in