SharePoint Study Notes-ribbon series-5. Add new controls to ribbon (custom tab for Users)

Source: Internet
Author: User
Tags visual studio 2010

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

--

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.