Hi,
I'm trying to load a UserControl in a RadWindow. It gets displayed but the button click events do not get fired.
When doing the exact same thing with a RadDock, the button click event in the UserControl gets call as expected. Here is the code used to load the UserControl (largely inspired from this thread).
Can you tell me what is wrong ? Why is the Button click event not callled with the RadWindow, but called with the RadDock ?
Thanks,
Dominic.
Default.aspx:
Default.aspx.cs
TestControl.ascx
TestControl.ascx.cs :
I'm trying to load a UserControl in a RadWindow. It gets displayed but the button click events do not get fired.
When doing the exact same thing with a RadDock, the button click event in the UserControl gets call as expected. Here is the code used to load the UserControl (largely inspired from this thread).
Can you tell me what is wrong ? Why is the Button click event not callled with the RadWindow, but called with the RadDock ?
Thanks,
Dominic.
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> |
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="true" VisibleStatusbar="false" runat="server" /> |
<telerik:RadDockLayout runat="server" ID="RadDockLayout1"> |
<telerik:RadDockZone runat="server" ID="RadDockZone1" Width="300" MinHeight="200" /> |
</telerik:RadDockLayout> |
</form> |
</body> |
</html> |
Default.aspx.cs
void Page_Init(object sender, EventArgs e) |
{ |
this.EnableViewState = false; |
RadWindow RadWindow1 = new RadWindow(); |
RadWindow1.ID = "RadWindow1"; |
RadWindow1.VisibleOnPageLoad = true; |
RadWindow1.ContentTemplate = new TestTemplate(Page); |
RadWindowManager1.Windows.Add(RadWindow1); |
RadDock RadDock1 = new RadDock (); |
RadDock1.Text = RadDock1.ID = "RadDock1"; |
RadDock1.ContentTemplate = new TestTemplate(this.Page); |
RadDockZone1.Controls.Add(RadDock1); |
} |
} |
internal class TestTemplate : ITemplate |
{ |
private Page _page; |
public TestTemplate(Page page) |
{ |
_page = page; |
} |
public void InstantiateIn(Control container) |
{ |
System.Web.UI.UserControl userControl; |
userControl = (System.Web.UI.UserControl)_page.LoadControl("~/TestControl.ascx"); |
container.Controls.Add(userControl); |
} |
} |
TestControl.ascx
<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="TestControl.ascx.cs" Inherits="WebApplication1.TestControl" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
User control used as template with button events. |
<div> |
<asp:Button ID="btn1" runat="server" Text="Button with tooltip" ToolTip="Hello World" /> |
<asp:Button ID="btn2" runat="server" Text="Button" /> |
</div> |
<p><asp:Literal ID="ltrl" runat="server" /></p> |
<telerik:RadToolTipManager ID="rttm" runat="server" AutoTooltipify="true" /> |
TestControl.ascx.cs :
public partial class TestControl : System.Web.UI.UserControl |
{ |
override protected void OnInit(EventArgs e) |
{ |
base.OnInit(e); |
btn1.Click += new EventHandler(btn1_Click); |
btn2.Click += new EventHandler(btn2_Click); |
} |
void btn1_Click(object sender, EventArgs e) |
{ |
ltrl.Text = "Button 1 was clicked"; |
} |
protected void btn2_Click(object sender, EventArgs e) |
{ |
ltrl.Text = "Button 2 was clicked"; |
} |
} |