Add to SharePoint 2010 Context Menu

Within SharePoint 2010, there is a ‘context menu’ that is shown when you click on a specific file – eg. DOCX.


This is actually known as the “Edit Control Block” or ECB.   Yep – another acronym for the kitbag.

To add functionality to the SharePoint 2010 ECB, we have to create a new SharePoint feature, with some XML within an ELEMENTS.XML file.

Here’s the steps to follow :

  • Open Visual Studio 2010
  • Click on “Empty SharePoint Project”
  • Name the project : NewContextMenuButton
  • Choose to ‘deploy as a farm solution’ when prompted

Within the new project, we need to add a new ‘elements’ file – and subsequent feature, etc.

  • Right-click on the project, and choose Add > New Item
  • Choose ‘Empty Element’
  • Enter the name as : NewContextMenuButton
  • Click CTRL+A (select all) and then Delete.
  • Paste in the following XML

<Elements xmlns=””>
  <CustomAction Id=”SPR.CustomButton”
                Title=”Custom Button”
                Description=”Click this button to see something magical occur…” >
    <UrlAction Url=”javascript: alert(‘Hello World !’)” />

You can now simply right-click – and choose DEPLOY – that’s it…!     The feature & package name will be the default values – but they can be changed if needed.

Also – the IMAGE being used was just something that I found in the ‘layouts’ area of SharePointRoot.

Here’s the new Context Menu item – sorry, new addition to the Edit Control Block :


This will create a new entry for “DOCX” files – based on the “RegistrationType”.

You can also register for a specific Content Type, or ProgId – more information is available :

Next : How to call code – ie. do something useful !

UPDATE : Great post from Matt Thornton – who has extended this example beyond the ‘Hello World’ – with some Custom Code (C#)

2 thoughts on “Add to SharePoint 2010 Context Menu

  1. MT September 27, 2011 / 3:52 pm

    Did you ever write part 2? Hello World is great and all…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s