Events not fired for Dynamically Created Controls in VS2005 ASP.NET 2.0

R

Richard Huang

Following code worked for VS.NET 2005 Beta 2, but not for the final
release. When clicking the button, it posted back, but the
"addQL_Click" method is not called. Any suggestion would be very much
appreciated.

public class MyEditor: EditorPart, INamingContainer
{
protected override void CreateChildControls()
{
Controls.Clear();
addButton("Add", "Add", new EventHandler(this.addQL_Click),
this.Controls);
ChildControlsCreated = true;
}
private void addButton(string buttonID, string buttonText,
EventHandler
myHandler, System.Web.UI.ControlCollection myControls)
{
Button _actionButton = new Button();
_actionButton.ID = buttonID;
_actionButton.Text = buttonText;
if (myHandler != null)
_actionButton.Click += myHandler;
myControls.Add(_actionButton);
}

private void addQL_Click(object sender, EventArgs e)
{
}
}
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top