Composite Control events dont fire.

A

Arthur Puszynski

I cannot figure out why this doesnt work. This is almost exactly the same as
the samples I've seen but it doesnt work for me.

I am making a composite control with a button that has a click event but the
event never fires.
Here's my code:

public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{

protected override void CreateChildControls()
{
Button sButton = new Button();
sButton.Click +=new EventHandler(sButton_Click);
Controls.Add(sButton);
base.CreateChildControls ();
}

protected override void Render(HtmlTextWriter output)
{
Controls[0].RenderControl(output);
}

private void sButton_Click(object sender, EventArgs e)
{
((Button)Controls[0]).Text = "Clicked";

}

}

Any ides?

Thank you,

Art
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top