SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to register a custom action on a site collection that adds a button to the SharePoint ribbon. I want to do this using the object model and not declaratively in XML. Does anyone know of this is even possible? I've been looking at SPRibbonButton but cannot figure a way to achieve this.

share|improve this question
@orl78: Remember to mark questions as answered if you have an answer that works for you. This rewards those that help you out. Thanks! – Alex Angas Sep 1 '10 at 7:19

You can use the SPRibbon.RegisterDataExtension() to insert Ribbon stuff. You're inserting XML though through this method.

share|improve this answer
Thanks Wictor, yeah I had seen this method and thought it may be the solution. I was hoping though that there may be a way to set properties on an spribbonbutton object and then call .add() or similar. Thx again – Anonymous Aug 28 '10 at 19:50

The following links to an example using the RegisterDataExtension() method

Walkthrough: Creating a Custom Web Part with a Contextual Tab

share|improve this answer

Your Answer


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