I have here a small problem with a dynamically generated buttons and their event handler in asp.net. I generate a flexible table with additional Buttons for special users. T
You must have to place that code in page_load
or page_init
event.
protected void Page_Load()
{
Button ButtonChange = new Button();
ButtonChange.Text = "Change";
ButtonChange.ID = "change_" + i.ToString();
ButtonChange.Font.Size = FontUnit.Point(7);
ButtonChange.ControlStyle.CssClass = "button";
ButtonChange.Click += new EventHandler(test);
}
Read MSDN article - How to: Add Controls to an ASP.NET Web Page Programmatically?