Enterprise software development and consulting for various organizations, industries and domains.

Showing posts with label Ribbon. Show all posts
Showing posts with label Ribbon. Show all posts

Wednesday, July 28, 2010

Sharepoint 2010 Ribbon: Enrich custom dialogs

Standard dialogs in SharePoint 2010 come with ribbon component. In order to enrich your custom dialog with ribbon follow these steps.

1. Define CustomAction element in a declarative XML. I recommend to put this in a feature as described here MSDN: CustomAction Element

Note: Do NOT use dots in CustomAction Id, otherwise all buttons with associated actions will be disabled.

2. Register Ribbon on a page. I made it programmatically by the following code in the PreRender event handler.
protected void Page_PreRender(object sender, EventArgs e)
{
    SPRibbon current = SPRibbon.GetCurrent(this);

    if (current != null)
    {
        current.MakeTabAvailable("Ribbon.ClassifyDialog.Edit");
        current.InitialTabId = "Ribbon.ClassifyDialog.Edit";
        current.CommandUIVisible = true;
        current.Minimized = false;
    }
} 

3. Register javascript component containing client side logic on a page using SP.Ribbon.PageManager.get_instance().addPageComponent()
Link with method description is here MSDN: addPageComponent.

This is it. Enjoy professional look'n'feel of your dialogs.