Hi there,
I'm using the RadAjaxManager to handle AJAX in my site. When using standard .NET controls (linkbutton, literal etc.) the AJAX works and client events fire as expected. However, when I use my own controls (from a class library) the AJAX works, but the client events do not fire. Do you have any ideas why that might be?
Thanks,
Jon.
the code in my initiating control is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xach.WebControls;
using Telerik.Web.UI;
namespace Xach.CMS.WebControls
{
public class LightboxLink : Control, INamingContainer
{
public string Control { get; set; }
public string LightboxControllerID { get; set; }
public string Text { get; set; }
public string CssClass { get; set; }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// wire up ajax
List<Control> list = Page.Master.FindControlsByType(typeof(RadAjaxManager));
RadAjaxManager manager = list[0] as RadAjaxManager;
manager.AjaxSettings.AddAjaxSetting(this, Page.Master.FindControlRecursive(LightboxControllerID));
/*manager.AjaxSettings[manager.AjaxSettings.Count - 1].EventName = "lightbox";*/
}
protected override void CreateChildControls()
{
LinkButton button = new LinkButton() { Text = Text, CssClass = CssClass };
button.ID = "LbButton";
button.Click += new EventHandler(button_Click);
button.OnClientClick = "lightBox.start()";
Controls.Add(button);
}
protected void button_Click(object sender, EventArgs e)
{
LightboxController controller = (LightboxController)Page.Master.FindControlRecursive(LightboxControllerID);
controller.CreateLightboxControl(Control);
}
}
}
and in the updated control:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Xach.CMS.WebControls
{
public class LightboxController : Control
{
protected override void CreateChildControls()
{
base.CreateChildControls();
}
public void CreateLightboxControl(string control)
{
//HttpContext.Current.Response.Write("loaded");
Control ctrl = Page.LoadControl(control);
Controls.Add(ctrl);
}
}
}
I'm using the RadAjaxManager to handle AJAX in my site. When using standard .NET controls (linkbutton, literal etc.) the AJAX works and client events fire as expected. However, when I use my own controls (from a class library) the AJAX works, but the client events do not fire. Do you have any ideas why that might be?
Thanks,
Jon.
the code in my initiating control is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xach.WebControls;
using Telerik.Web.UI;
namespace Xach.CMS.WebControls
{
public class LightboxLink : Control, INamingContainer
{
public string Control { get; set; }
public string LightboxControllerID { get; set; }
public string Text { get; set; }
public string CssClass { get; set; }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// wire up ajax
List<Control> list = Page.Master.FindControlsByType(typeof(RadAjaxManager));
RadAjaxManager manager = list[0] as RadAjaxManager;
manager.AjaxSettings.AddAjaxSetting(this, Page.Master.FindControlRecursive(LightboxControllerID));
/*manager.AjaxSettings[manager.AjaxSettings.Count - 1].EventName = "lightbox";*/
}
protected override void CreateChildControls()
{
LinkButton button = new LinkButton() { Text = Text, CssClass = CssClass };
button.ID = "LbButton";
button.Click += new EventHandler(button_Click);
button.OnClientClick = "lightBox.start()";
Controls.Add(button);
}
protected void button_Click(object sender, EventArgs e)
{
LightboxController controller = (LightboxController)Page.Master.FindControlRecursive(LightboxControllerID);
controller.CreateLightboxControl(Control);
}
}
}
and in the updated control:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Xach.CMS.WebControls
{
public class LightboxController : Control
{
protected override void CreateChildControls()
{
base.CreateChildControls();
}
public void CreateLightboxControl(string control)
{
//HttpContext.Current.Response.Write("loaded");
Control ctrl = Page.LoadControl(control);
Controls.Add(ctrl);
}
}
}