P
Patrick
Hi
I have an aspx-page, where I load my custom-control (see below). The problem
I have is that the event does not fire. I really cant figure out why. Just
to know, I derive from System.Web.UI.Control, becaues later on I want to add
some more controls, but first I have to solve this problem.
Has someone an idea?
Thanks
Patrick
*************** default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = new Mycustomcontrol();
this.form1.Controls.Add(ctrl);
}
*************** Mycustomcontrol.cs
public class Mycustomcontrol: System.Web.UI.Control
{
private Button bt;
protected override void CreateChildControls()
{
bt = new Button();
bt.Text = "test";
this.Controls.Add(bt);
bt.Click += new EventHandler(bt_Click);
}
protected void bt_Click(object sender, EventArgs e)
{
System.Web.HttpContext.Current.Response.Write("button was clicked");
}
}
I have an aspx-page, where I load my custom-control (see below). The problem
I have is that the event does not fire. I really cant figure out why. Just
to know, I derive from System.Web.UI.Control, becaues later on I want to add
some more controls, but first I have to solve this problem.
Has someone an idea?
Thanks
Patrick
*************** default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = new Mycustomcontrol();
this.form1.Controls.Add(ctrl);
}
*************** Mycustomcontrol.cs
public class Mycustomcontrol: System.Web.UI.Control
{
private Button bt;
protected override void CreateChildControls()
{
bt = new Button();
bt.Text = "test";
this.Controls.Add(bt);
bt.Click += new EventHandler(bt_Click);
}
protected void bt_Click(object sender, EventArgs e)
{
System.Web.HttpContext.Current.Response.Write("button was clicked");
}
}