Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
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 –  Furqan Jul 21 '12 at 8:28
    
Thanks a lot. but this link not found. –  ar.gorgin Jul 21 '12 at 8:52
    

2 Answers 2

up vote 0 down vote accepted

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

share|improve this answer
    
Nice info! But I think he wants to add the button to the already existing "Page" tab. –  Vardhaman Deshpande Jul 21 '12 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 Jul 23 '12 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/

share|improve this answer
    
Thanks a lot. I use Library, but How can I get access to the controls within the web part? –  ar.gorgin Jul 22 '12 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. –  Vardhaman Deshpande Jul 22 '12 at 8:28
    
I have a SpGridView in webpart. I want whne select a row of SpGridView change the link on ribbon. –  ar.gorgin Jul 22 '12 at 9:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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