4/30/2011

Add Custom Ribbon Button in SharePoint 2010

This is my personal format to add a Custom Ribbon Button in SharePoint 2010 :

Code :
<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<CustomAction
Id="CustomRibbonTab"
Location="CommandUI.Ribbon.ListView"
RegistrationId="101"
RegistrationType="List"
Sequence="5">

<CommandUIExtension>

<CommandUIDefinitions>

<CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">

<Button
Id="Ribbon.Documents.New.RibbonTest"
Alt="Test Button"
Sequence="5"
Command="Test_Button"
LabelText="Click Me!"
Image32by32="/_layouts/images/ribbon_blog_32.png"
Image16by16="/_layouts/images/ribbon_blog_16.png"
TemplateAlias="o1" />

</CommandUIDefinition>

</CommandUIDefinitions>

<CommandUIHandlers>

<CommandUIHandler
Command="Test_Button"
CommandAction="javascript:alert('Why Did You Clicked Me?');" />

</CommandUIHandlers>

</CommandUIExtension>

</CustomAction>

</Elements>

0 comments: