QuickTip: Specify the Active Ribbon Tab from the QueryString

Posted: Grant | Comments: 1 | November 16th, 2010
Nov 16

For all of us that have been using Office 2007 and newer, you have surely become comfortable with the Ribbon in Office. As I am sure most of you know, SharePoint 2010 incorporates the Ribbon as a very impressive set of JavaScript driven features. However, as much as I love the Ribbon architecture in SharePoint, not everyone shares my sentiment. I’ve seen many users that are not accustomed to the context-driven nature of this sophisticated navigation system.

With that being said, one of the common scenarios I have seen is where a link to a list view (either in a Summary Link Web Part, or Content Editor Part, etc.) is clicked and the resulting page doesn’t have any actions until the user clicks on an item. At which point, the context of the user action has changed and the appropriate tab is selected. Fortunately for the SharePoint power user, there is an easy way to circumvent this end-user frustration.

We can set the active tab when the view is loaded by providing the InitialTabId variable to the querystring and setting its value to the ID of a Ribbon tab on the page. For example, setting the Documents tab active on a view in a Document Library can be accomplished like so: http://server/DocumentLibrary/AllItems.aspx?InitialTabId=Ribbon.Document.

Now, you may be asking: “The Ribbon tabs are different based on the type of list. How do I find the ID of the tab?”. Excellent question. If you are a SharePoint power user and you do not have access to the hive, you can’t really root around in CMDUI.xml to find the Ribbon tab ID. However, you can use Internet Explorer to find the tab ID!

Scenario: I want the Events tab to be the active tab when a Calendar list view is displayed.

Perform the following steps:

  1. Navigate to the Calendar list.
  2. Click on the Events tab in the Ribbon.
  3. Press F12 to activate the IE Developer Tools
  4. Click the Selector tool (arrow) and then click on the Events tab in IE. You’ll notice from the screen capture below that this selects the <span /> tag for the menu item. If you look at the ID attribute of the <li /> tag that is the grandparent element of the <span /> you’ll notice that the ID of the Ribbon tab is right there for you to use!

    Set Active Ribbon

    Set Active Ribbon

Using this technique, you can quickly and non-invasivly set focus to a Ribbon tab in SharePoint without code.

1 comment
  1. Dave says:

    Good article, however Ribbon.Document is not working on my environment. Even Ribbon.Library, which is right beside it in the same contextual tab group, works fine as do other tabs.

    Any link I create ending in *.aspx?InitialTabId=Ribbon.Document is getting redirected or truncated by sharepoint or something else to *.aspx?”

    Any ideas what might cause this? Sharepoint Server 2010 Standard on a Server 2k8R2 VM. We’re running a 3rd party solution (pdfsharepoint.com) that adds a button to the Document Library ribbon under the Documents tab but this is the only Library that has the button added. The rest of the libraries are standard Document libraries with stock ribbons.

Leave a Comment