SIGN UP MEMBER LOGIN:    
ARTICLE

How to create custom button in SharePoint 2010 Ribbon User Interface

Posted by Vijai Anand Articles | SharePoint December 13, 2010
In this article we will be seeing how to create a custom button in the SharePoint 2010 Ribbon user interface.
Reader Level:


In this article we will be seeing how to create a custom button in the SharePoint 2010 Ribbon user interface.

Steps Involved:

I. Open Visual Studio 2010.

ii. Go to File => New =>Project.

iii. Select Empty SharePoint project template from the installed template SharePoint => 2010.

iv. Enter the Name and click OK.

v. Check the option "Deploy as a Sandbox solution".

vi. Click Ok.

vii. Right click on the solution and select "Add a new item".

viii. Select Empty Element template, enter the Name and click Ok.

ix. In the Elements.xml replace the code with the following.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
  Id="Demo_CustomButton"
  RegistrationType="List"
  RegistrationId="101"
  Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <
CommandUIDefinitions>
        <
CommandUIDefinition
         Location="Ribbon.Documents.New.Controls._children">
          <Button
           Id="Ribbon.Documents.New.Controls.Demo_CustomButton"
           Alt="Demo_CustomButton"
           Sequence="10"
           Image32by32="/_layouts/images/PPEOPLE.GIF"
           Command="Demo_CustomButton"
           LabelText="My Custom Button"
           TemplateAlias="o2"/>
        </CommandUIDefinition>
      </
CommandUIDefinitions>
      <
CommandUIHandlers>
        <
CommandUIHandler
         Command="Demo_CustomButton"
         CommandAction="javascript:alert('My custom button!');" />
      </CommandUIHandlers>
    </
CommandUIExtension>
  </
CustomAction>
</
Elements>

x. Go to the SharePoint site where you have deployed your solution.

xi. Go to Shared Documents =>Library Tools => Documents.

xii. You will see My Custom Button in the Ribbon User Interface.

1.gif

xiii. Click on the button and you will see an alert message.

2.gif









  

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor