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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top