Create custom action to list instance

SPPList list;//custom list 
 SPUserCustomAction action = list.UserCustomActions.Add();
 action.Title = titleAction;
 action.Sequence = 20;
 action.Location = "CommandUI.Ribbon";
action.CommandUIExtension=@"
<CommandUIExtension>
<CommandUIDefinitions>
 <CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">
 <Button Id="CustomAction.TestButton"
Sequence="0"
 Image32by32="/_layouts/images/mewa_rightb.gif"
 Command="TestCommmand"
 LabelText="Button de test"
 TemplateAlias="o1"
 />
 </CommandUIDefinition>
</CommandUIDefinitions>
 <CommandUIHandlers>
 <CommandUIHandler
 Command="TestCommmand" EnabledScript="javascript:return true;"
 CommandAction="javascript:alert(‘Button test’)"/>
 </CommandUIHandlers>
 </CommandUIExtension>";
action.Update();
list.Update();
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s