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

Discussion in 'ASP .Net Web Controls' started by Richard Huang, Dec 7, 2005.

  1. 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)
    {
    }
    }
     
    Richard Huang, Dec 7, 2005
    #1
    1. Advertising

  2. Richard Huang

    JJ Guest

    RE: Events not fired for Dynamically Created Controls in VS2005 ASP.NE

    Hi Richard,

    I got this problem too. Any solutions?

    Thanks

    "Richard Huang" wrote:

    > 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)
    > {
    > }
    > }
    >
    >
     
    JJ, Jan 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amelyan
    Replies:
    2
    Views:
    693
    Amelyan
    Nov 5, 2005
  2. ami
    Replies:
    2
    Views:
    1,227
    Valerio Santinelli
    May 30, 2007
  3. msimmons
    Replies:
    0
    Views:
    514
    msimmons
    Jul 16, 2009
  4. Amelyan

    Dynamically Created Controls in VS2005 ASP.NET 2.0

    Amelyan, Nov 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    136
    Amelyan
    Nov 4, 2005
  5. Replies:
    5
    Views:
    193
    Alessandro Zifiglio
    Aug 2, 2006
Loading...

Share This Page