I have a webpart with custom setting.

I add 2 property to webpart setting. I want add button to Page tab ribbon when webpart added to page and value set for the property.

It is possible that add a button to Page tab ribbon?

  • Yes, you can add a button to page tab ribbon when you add your web part.For this you need to implement your Ribbon Button as a seperate feature and enable it, and in Enabledscript property of your ribbon element you can check if your web part is on the page you can enable the ribbon button.A starting point can be http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-document-sets-custom-ribbon-buttons-with-custom-code Commented Jul 21, 2012 at 8:28
  • Thanks a lot. but this link not found.
    – ar.gorgin
    Commented Jul 21, 2012 at 8:52
  • thorntontechnical.com/tech/sharepoint/… Commented Jul 21, 2012 at 10:24

2 Answers 2


You can create a Ribbon Tab which shows up when your web part is selected, this is what is called a Contextual Tab.

MSDN has an article: Walkthrough: Creating a Custom Web Part with a Contextual Tab

It's a lot of work, but as Wictor Wilén writes in CKSDev version 2.0 is released - includes Contextual Web Part SPI it's been made a lot easier by CKSDev

  • Nice info! But I think he wants to add the button to the already existing "Page" tab. Commented Jul 21, 2012 at 18:15
  • Thanks a lot, I use this but i have a problem: when i edit js file and deploy, it is run first js file and don't show changed!
    – ar.gorgin
    Commented Jul 23, 2012 at 8:06

From your question, I understand that you want to add the button to the Page Tab in the Ribbon whenever a particular WebPart is added to the page.

You can do this with the JavaScript Client Object Model: http://msdn.microsoft.com/en-us/library/hh185004

Here is a list of all Locations where the Button can be added: http://msdn.microsoft.com/en-us/library/bb802730

If you want to go the Server Side way, you can add the Ribbon button like this: http://sp365.co.uk/2011/09/programmatically-add-ribbon-custom-action-to-an-existing-list/

Also, I would like to mention that there is an awesome Library on Codeplex for adding ribbon buttons: http://spribbon.codeplex.com/

  • Thanks a lot. I use Library, but How can I get access to the controls within the web part?
    – ar.gorgin
    Commented Jul 22, 2012 at 6:35
  • You can get access to the code from the webpart by the Ribbon Objects provided in the JS Client Object Model as well as the Server Side (C#) code. Check out the examples in the links. Commented Jul 22, 2012 at 8:28
  • I have a SpGridView in webpart. I want whne select a row of SpGridView change the link on ribbon.
    – ar.gorgin
    Commented Jul 22, 2012 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.