RibbonLayoutsPage I need to manually activation Tab

Sep 21, 2012 at 7:58 AM
Edited Sep 21, 2012 at 8:02 AM

Hi, 

I Crate Application page , use RibbonLayoutsPage .

 

but I deployment, I see the page , this Tab is auto activation .

And I use ILSpy see FluentRibbon.dll source Code. I think need user User preach a parameter

if(needMakeTabAvailable ){ Current. MakeTabAvailable } ..

  .  thanks.

 

public void AddRibbonTabToPage(TabDefinition definition, Page page, bool makeInitial)
{
	if (SPRibbon.GetCurrent(page) == null)
	{
		throw new Exception("SPRibbon.GetCurrent returned null for the specified page!");
	}
	this.AddRibbonExtension(XmlGenerator.Current.GetTabXML(definition), page, "Ribbon.Tabs", makeInitial);
	this.AddGroupTemplatesRibbonExtensions(definition.GroupTemplates, page);
	RibbonCommandRepository.Current.AddCommands(definition);
	page.PreRenderComplete -= new EventHandler(this.page_PreRenderComplete);
	page.PreRenderComplete += new EventHandler(this.page_PreRenderComplete);
	Ribbon current = SPRibbon.GetCurrent(page);
	current.MakeTabAvailable("Ribbon." + definition.Id);
	if (makeInitial)
	{
		current.InitialTabId = "Ribbon." + definition.Id;
	}
}
Sep 21, 2012 at 8:22 AM
Edited Sep 21, 2012 at 8:22 AM

hi , all .

In application page , you can override OnPreRender , change makeInitial

 parameter true to false. 

 

protected override void OnPreRender(EventArgs e)
        {
            TabDefinition tabDefinition = this.GetTabDefinition();
            if (tabDefinition != null && !base.DesignMode)
            {
                RibbonController.Current.AddRibbonTabToPage(tabDefinition, this, false);
            }
        }

 

It's ok