I have a project with a number of custom ribbons: a couple are bound to contenttypes, some are activated through webparts and some are (sub)site-wide and are supposed to be activated by a delegate control.
All the ribbons are in a site-scoped feature, and the delegate control is in a web-scoped feature, because these ribbons are supposed to show only on the subsites.
However, something does not work. I think it's not the ribbon-xml because if I bind it to a contenttype the ribbon shows up as expected. If I attach to the IIS Worker process and reload the page, the breakpoint in the OnPreRender of the delegate control is not reached. So my best guess is that something is wrong with the delegate control. What that is I don't know.
ShowAdminMenuControl.cs:
namespace MyProject.Ribbons.ShowAdminMenu
{
class ShowAdminMenuControl : WebControl
{
private bool isLeverancierSite;
private bool isRegisteredUser;
private string typeGebruiker;
private int? gebruikerId;
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
SPWeb web = SPContext.Current.Web;
isLeverancierSite = Functions.GetWebProperty(web, WebProperties.SiteType) == SiteTypes.Leverancier;
isRegisteredUser = Functions.GetCurrentGebruiker(web, out typeGebruiker, out gebruikerId);
#region show ribbon
if (!isRegisteredUser || typeGebruiker == Gebruiker.Admin)
{
SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
if (ribbon != null)
{
ribbon.Minimized = false;
ribbon.CommandUIVisible = true;
string adminMenuTabId = String.Format("MyProject.Ribbon.{0}.AdminMenu.Tab", (isLeverancierSite ? "Leverancier" : "Intermediair"));
if (!ribbon.IsTabAvailable(adminMenuTabId))
{
ribbon.MakeTabAvailable(adminMenuTabId);
}
ribbon.InitialTabId = adminMenuTabId;
}
}
#endregion
}
}
}
Elements.xml of ShowAdminMenu
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="AdditionalPageHead"
Sequence="99"
ControlAssembly="$SharePoint.Project.AssemblyFullName$"
ControlClass="MyProject.Ribbons.ShowAdminMenu.ShowAdminMenuControl"/>
</Elements>
Elements.xml of AdminMenu:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="MyProject.Ribbon.Leverancier.AdminMenu"
Location="CommandUI.Ribbon"
Title="Adminmenu Leveranciersite">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Tabs._children">
<Tab Id="MyProject.Ribbon.Leverancier.AdminMenu.Tab"
Title="Beheer"
Description="Beheerpagina's voor Admins"
Sequence="21">
<Scaling Id="MyProject.Ribbon.Leverancier.AdminMenu.Scaling">
<MaxSize Id="MyProject.Ribbon.Leverancier.AdminMenu.Scaling.MaxSize"
GroupId="MyProject.Ribbon.Leverancier.AdminMenu.Group"
Sequence="1"
Size="Large"/>
<Scale Id="MyProject.Ribbon.Leverancier.AdminMenu.Scaling.Scale"
GroupId="MyProject.Ribbon.Leverancier.AdminMenu.Group"
Sequence="2"
Size="Large"/>
</Scaling>
<Groups Id="MyProject.Ribbon.Leverancier.AdminMenu.Groups">
<Group Id="MyProject.Ribbon.Leverancier.AdminMenu.Group"
Description="Lijsten"
Title="Lijsten"
Sequence="11"
Template="MyProject.Ribbon.Leverancier.AdminMenu.Template">
<Controls Id="MyProject.Ribbon.Leverancier.AdminMenu.Controls">
<Button Id="MyProject.Ribbon.Leverancier.AdminMenu.Gebruikers"
Command="MyProject.Commands.Leverancier.AdminMenu.Gebruikers"
Sequence="11"
Description="Beheer gebruikers"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-144" Image16by16Left="0"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-256"
LabelText="Gebruikers"
TemplateAlias="o1"/>
<Button Id="MyProject.Ribbon.Leverancier.AdminMenu.Statussen"
Command="MyProject.Commands.Leverancier.AdminMenu.Statussen"
Sequence="12"
Description="Beheer statussen"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-144" Image16by16Left="0"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-256"
LabelText="Statussen"
TemplateAlias="o1"/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="MyProject.Ribbon.Leverancier.AdminMenu.Template">
<Layout Title="Large">
<OverflowSection Type="OneRow" TemplateAlias="o1" DisplayMode="Large" />
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="MyProject.Commands.Leverancier.AdminMenu.Gebruikers"
CommandAction="javascript:window.location='{SiteUrl}/Lists/Gebruikers';"/>
<CommandUIHandler Command="MyProject.Commands.Leverancier.AdminMenu.Statussen"
CommandAction="javascript:window.location='{SiteUrl}/Lists/Statussen';"/>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<CustomAction Id="MyProject.Ribbon.Script"
Location="ScriptLink"
ScriptSrc="/_layouts/MyProject/Ribbons/MyProject.ribbon.js" />
</Elements>