I am writing a User Control in C# that dynamically generates some text boxes and two buttons. For all the html on the page I am overriding the render method, I also render my Button/Textbox controls as well using the “.RenderControl ”. However, when I do that I can’t seem to get my button click events to work.
Code:
protected void LoadSearchButtons(HtmlTextWriter htmlWriter)
{
searchButton = new Button();
searchButton.Text = "Search";
searchButton.RenderControl(htmlWriter);
htmlWriter.Write(" ");
resetButton = new Button();
resetButton.Text = "Reset";
resetButton.OnClientClick = "resetButton_Click"; *I thought added this might help, but it does not.
resetButton.RenderControl(htmlWriter);
resetButton.Click+= new EventHandler(resetButton_Click);
}
protected void resetButton_Click(object sender, System.EventArgs e) {
}
}