composite control does not fire event

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");
}

}
 
P

Patrick

no, it was easier, just had to implement the INamingContainer Interface, now
it works
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top