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

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer

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.