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 :
<CustomAction Id=”SPR.CustomButton”
RegistrationType=”FileType”
RegistrationId=”docx”
Location=”EditControlBlock”
ImageUrl=”/_layouts/IMAGES/DOCLINK.GIF”
Sequence=”600″
Title=”Custom Button”
Description=”Click this button to see something magical occur…” >
<UrlAction Url=”javascript: alert(‘Hello World !’)” />
</CustomAction>
< /Elements>
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”.
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
- 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
<CustomAction Id=”SPR.CustomButton”
RegistrationType=”FileType”
RegistrationId=”docx”
Location=”EditControlBlock”
ImageUrl=”/_layouts/IMAGES/DOCLINK.GIF”
Sequence=”600″
Title=”Custom Button”
Description=”Click this button to see something magical occur…” >
<UrlAction Url=”javascript: alert(‘Hello World !’)” />
</CustomAction>
< /Elements>
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”.
No comments:
Post a Comment