I cannot get the button event inside my custom server control to raise. Below is an example written in 3.5. I believe my events are in order from examples listed online. Any help?
[
ToolboxData("<{0}:TestButton runat=server>{0}:TestButton>")]public class TestButton : WebControl{
public Button Tester { get; set; } public Label ClickedIndicator { get; set; } protected override void CreateChildControls(){
base.CreateChildControls();
Tester =
new Button();Tester.ID = "btnTest";
Tester.Text = "Increment Count"; Tester.Click += new EventHandler(Tester_Click);
this.Controls.Add(Tester);
ClickedIndicator = new Label();
ClickedIndicator.ID = "lblClickCount";
ClickedIndicator.Text = "not clicked";
this.Controls.Add(ClickedIndicator);
} protected void Tester_Click(object sender, EventArgs e)
{
ClickedIndicator.Text = "clicked";
}
Mawhrin SkelPosted Mar 3, 2015, 11:10 AM
JustinPosted May 14, 2008, 12:24 PM
I resolved this issue by deriving my control from "CompositeControl" instead of "WebControl". Hope this is helpful to the next victim!