Extending the SharePoint 2013 Ribbon Using Visual Studio
Part 1: Creating a custom action for task lists
August 19, 2014
![Extending the SharePoint 2013 Ribbon Using Visual Studio Extending the SharePoint 2013 Ribbon Using Visual Studio](https://eu-images.contentstack.com/v3/assets/blt07f68461ccd75245/blt1380df33ac376ca1/661cef102c4ced9aaf0ebb1a/man-woman-computer-screen_0_3.jpg?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
Extending the Ribbon is one of the most common tasks in SharePoint. If you’re familiar with this task from SharePoint 2010, you will recognize the XML structure that’s used. However, in SharePoint 2013 much of the underlying XML is generated for you using wizards in Visual Studio.
This makes a great starting point for more complex projects, and it also makes it very easy to get started and add Ribbon functionality to existing projects.
In this scenario, we’re going to create a simple Ribbon custom action for Task lists. Clicking our button takes the user to the home page of the app, which greets the current user.
In Visual Studio 2013, click File, New,Project.
Under the heading Office/SharePoint, click Apps.
Choose App for SharePoint (see Figure 1).
![](https://cet.informabi.com/sites/sharepointpromag.com/files/uploads/2014/08/8-19-14%20Rogers%20Fig1.png?width=560&auto=webp&quality=80&disable=upscale)
Figure 1
Give your app a name and choose the proper location.
Click OK.
In the dialog that opens, type in the name of your development SharePoint 2013 site.
In the options for hosting your app, choose SharePoint-hosted.
Click Finish.
In the Solution explorer, right-click the name of your project and select Add, New Item… (see Figure 2).
![](https://cet.informabi.com/sites/sharepointpromag.com/files/uploads/2014/08/8-19-14%20Rogers%20Fig2.png?width=560&auto=webp&quality=80&disable=upscale)
Figure 2
In the Office/SharePoint section, select Ribbon Custom Action.
Give your Ribbon Custom Action a name and click Add (see Figure 3).
![](https://cet.informabi.com/sites/sharepointpromag.com/files/uploads/2014/08/8-19-14%20Rogers%20Fig3.png?width=560&auto=webp&quality=80&disable=upscale)
Figure 3
In the dialog that opens, select Host Web.
For Where is the custom action scoped to? choose List Template.
For Which particular item is the custom action scoped to? choose Tasks.
Click Next.
For Where is the control located? Choose Ribbon.ListItem.Actions.
For What is the label text for the button control? type a brief (1-3 words) description to appear on the new Ribbon button.
For Where does the button control navigate to? type the path to the homepage in your project.
Click Finish.
Take a moment to look through the XML the wizard provided. This is a great starting point, because it takes some of the guess work out of designing your custom action (see Figure 4).
In particular, the RegistrationType and the RegistrationId are already filled in specifically for Task Lists, removing the requirement for developers to know off hand—or keep a cheat sheet around for—the specific Ids for a given list type.
![](https://cet.informabi.com/sites/sharepointpromag.com/files/uploads/2014/08/8-19-14%20Rogers%20Fig4.png?width=558&auto=webp&quality=80&disable=upscale)
Figure 4
Although this project is very simple, you can debug it and see the functionality that is already in place. Click Start or hit the F5 key to start debugging.
The app will build, install, and the home page will open in the browser, greeting the current user. You can imagine that this is what the user will see (Figure 5) when he or she clicks on your new Ribbon button in a Task list.
![](https://cet.informabi.com/sites/sharepointpromag.com/files/uploads/2014/08/8-19-14%20Rogers%20Fig5.png?width=433&auto=webp&quality=80&disable=upscale)
Figure 5
This is a great start, but we aren’t yet able to see our new button in action. I’ll cover installing the app and using the button in the next post.
About the Author
You May Also Like