Developer forum
E-mail notifications
Ribbonbar Extensibility
I'm trying the following:
public override void Load()
{
...
RibbonBarButton btn = new RibbonBarButton();
btn.ID = "btnMyID";
btn.Text = "MyBtn";
btn.Size = Dynamicweb.Controls.Icons.Icon.Size.Large;
btn.Image = Dynamicweb.Controls.Icons.Icon.Type.Key;
btn.EnableServerClick = true;
btn.Click += new EventHandler<EventArgs>(btn_Click);
...
}
void btn_Click(object sender, EventArgs e)
{
// do stuff
}
But the btn_Click EventHandler never catches the event.
What am i doing wrong?
Replies
Could you elaborate your problem ?
1. On what page you're trying to execute your add-in (is this a standard Dynamicweb page or is this the page that you created by yourself) ?
2. Do you place an add-in onto the "Add-ins" tab or do you use an existing tab ?
- Pavel
i'm trying to add a buttom to the edit page ribbonbar, in the administration.
the button is added nicely, but the onClick event never fires.
Here's my complete test code:
//-----------------------------------------------------------------------
// <copyright file="addinTest.cs" company="Corbiz">
// All rights reserved ® Corbiz
// </copyright>
//-----------------------------------------------------------------------
namespace addinTest
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.HtmlControls;
using Dynamicweb;
using Dynamicweb.Controls;
using Dynamicweb.Controls.Extensibility;
using Dynamicweb.Extensibility;
/// <summary>
/// For testing purposes
/// </summary>
[AddInName("addinTest")]
[AddInAuthor("Corbiz")]
[AddInDescription("For testing purposes ")]
[AddInTarget(RibbonBarAddInTarget.General.PageEdit)]
public class addinTest : RibbonBarAddIn
{
/// <summary>
/// Initializes a new instance of the <see cref="addinTest"/> class.
/// </summary>
/// <param name="ribbon">An instance of <see cref="T:Dynamicweb.Controls.RibbonBar">RibbonBar</see> object that contains an add-in.</param>
/// <remarks></remarks>
public addinTest(RibbonBar ribbon)
: base(ribbon)
{
}
/// <summary>
/// Performs "Load" stage.
/// </summary>
/// <remarks></remarks>
public override void Load()
{
RibbonBarGroup group = new RibbonBarGroup();
group.Name = "TestGroup";
RibbonBarButton btn = new RibbonBarButton();
btn.ID = "btnMyID";
btn.Text = "MyBtn";
btn.Size = Dynamicweb.Controls.Icons.Icon.Size.Large;
btn.Image = Dynamicweb.Controls.Icons.Icon.Type.Key;
btn.EnableServerClick = true;
btn.Click += new EventHandler<EventArgs>(btn_Click);
btn.OnClientClick = "Ribbon.toggleActive('" + btn.ClientID + "')";
group.AddItem(btn);
this.Ribbon.InsertGroup("Menupunkt", group, 6);
}
void btn_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
I fixed my issue with Ajax.
You must be logged in to post in the forum