2

I'm trying to add a custom button to a SP2010 ribbon in the DisplayFormToolbar for a list item. The list is external, although I don't think that matters but still...

This is my custom action definition:

  <CustomAction Id="{0116B081-B13E-4A4B-8F8D-EF7AC1E43BFD}"
                Location="DisplayFormToolbar"
                RegistrationType="List"
                RegistrationId="600"
                Sequence="1"
                ControlAssembly="myAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...."
                ControlClass="myNamespace.MyRibbonButton" />

myNamespace.MyRibbonButton class extends System.Web.UI.WebControls.Button and has some basic code inside OnInit.

When I access the display form of an item in the external list, in debug I can see that OnInit is executed, there is no exception in the logs... but the button does not show in the form!

I have specified my assembly with SafeControl so that's not the cause.

Even if I add this to my custom action is still does not display:

<CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children" />
      </CommandUIDefinitions>
    </CommandUIExtension>

What could I be missing?

1 Answer 1

3

SharePoint 2010 ribbon doesn't have anything in common with 2007's DisplayFormToolBar.

The custom action Location attribute should be set to "CommandUI.Ribbon" for adding something to ribbon.

Then, you should provide special XML for button. Since SP2010 ribbon is a client-side thing, no C# code is involved here.

You can find a simple example of adding a button to ribbon here:

P.S. Also, you can consider using SharePoint 2010 Fluent Ribbon API opensource project to work with ribbon in a simplified way. A quick how-to start can be found at project's documentation site. It is my project actually, and I cannot resist mentioning that it is a rather popular project and we use it in real-world projects at work intensively.

7
  • Are you saying that I can't use the ControlAssembly/ControlClass attributes to define my own control to show in the ribbon? Also, I've set the location to "CommandUI.Ribbon" and the button is still not displayed and now my code isn't executed anymore!
    – JohnDoDo
    Feb 6, 2012 at 10:21
  • That's right, ribbon controls could be defined using XML only, and actions for them are specified as JavaScript code. Feb 6, 2012 at 10:24
  • So what are the ControlAssembly and ControlClass attributes used for then?
    – JohnDoDo
    Feb 6, 2012 at 10:38
  • They may be used for some other customizations, which are performed through CustomActions. But not for ribbon customizations. Feb 6, 2012 at 10:49
  • Please consider the following MSDN article, which describes possibilities of Ribbon customizations: msdn.microsoft.com/en-us/library/ee539395.aspx Feb 6, 2012 at 10:50

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.