
Adding Custom Buttons to the SharePoint Ribbon
❘
359
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command=”ShowWrox”
CommandAction=”javascript:window.open(‘http://www.wrox.com’);” />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
This example illustrates the two required attributes: Command and CommandAction. Command
is the name of the command and links to the
Command attribute of the Button element in the
CommandUIDefinition defi nition. CommandAction specifi es script that will execute when
the handler is invoked (i.e., when the button is clicked). In the example, the action is to sim-
ply open a new window that navigates to the Wrox website.
8. At this point, you are fi nished with all necessary changes and are ready to deploy the solu-
tion. Right-click the project in the Solution Explorer and choose Deploy.
9. To test your change, open a browser and navigate to the site to which the solution was
deployed, and then navigate to a document library (if one does not exist you will need to
create one) and choose the Documents tab in the ribbon. You should see an icon next to the
New Folder button that says “Visit Wrox,” similar to the image shown in Figure 12-7. Click
the icon. A new browser should open and take you to the Wrox website.
FIGURE 12-7
584644c12.indd 359584644c12.indd 359 10/27/10 11:44:55 AM10/27/10 11:44:55 AM