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.

  • @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
    Commented Sep 1, 2010 at 7:19

2 Answers 2


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

  • 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
    Commented Aug 28, 2010 at 19:50

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

Walkthrough: Creating a Custom Web Part with a Contextual Tab

Your Answer

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