2

Can you please help me in order to add a button at Page tab in publishing page. I am able to add the button in the documents library but I am not able to add the button at Page tab.

Here is the XML which I am using for the same:

<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.Page.Manage.Controls._children">
      <Button Id="NewUIRibbonControl.EnableRating"
              Alt="EnableRating"
              Sequence="1981"
              Command="EnableRating"
              LabelText="Enable Rating"
              TemplateAlias="o1"/>
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers >
    <CommandUIHandler Command="EnableRating"
    CommandAction="javascript:alert('hi');"/>
  </CommandUIHandlers>
</CommandUIExtension>

And also how to call C# function from here. Instead of alert I want to call a C# function.

Please let me know what's wrong there.

Thanks

1 Answer 1

3

I think your Location property is wrong. Depending on your settings and page layout correct location for Page tab is Ribbon.WikiPageTab or Ribbon.WebPartPage. There is no tab defined as Ribbon.Page in \14\TEMPLATE\GLOBAL\XML\CMDUI.XML

You can easily check id of any tab if you use IE with Developing Tools or FireFox with FireBug to explore ribbon markup.

Example of ribbon markup - search for id of ul tag (it is Ribbon.WikiPageTab):

<div unselectable="on" class="ms-cui-tabContainer ">
    <ul unselectable="on" class="ms-cui-tabBody" id="Ribbon.WikiPageTab" role="tabpanel" aria-labelledby="Ribbon.WikiPageTab-title">
    <li unselectable="on" class="ms-cui-group" id="Ribbon.WikiPageTab.EditAndCheckout">
        <span unselectable="on" class="ms-cui-groupContainer">

Only possible solution to call C# function from ribbon is through postback. I think it would be difficult to apply this technique on publishing page. Here is article on MSDN blogs on how to do it inside webpart: Implementing a post back button in a SharePoint 2010 Web Part with contextual ribbon

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.