I create a button dynamically in the event PreRenderas follows:
Button myButton = new Button();
myButton.Text = "Test";
myButton.Click += new EventHandler(myButton_Click);
myDiv.Controls.Add(myButton);
This button is displayed in the browser, but when I click the button, the click event does not fire. I tried to create an identical button in the event PageLoad, and it works fine, but I have to create this button as an event PreRender, since the creation of this dynamic button or not depends on the value that I get only in this event. What can I do when I click the dynamic button created in PreRenderthe click event fires?
source
share