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. Advertisements

  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. Advertisements

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:
    765
    Amelyan
    Nov 5, 2005
  2. Bob Rock
    Replies:
    1
    Views:
    880
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
  3. ami
    Replies:
    2
    Views:
    1,382
    Valerio Santinelli
    May 30, 2007
  4. SevDer
    Replies:
    2
    Views:
    1,493
    Walter Wang [MSFT]
    Nov 13, 2007
  5. msimmons
    Replies:
    0
    Views:
    755
    msimmons
    Jul 16, 2009
  6. Robert Sheppard

    Dynamically Created Controls Not Firing Events

    Robert Sheppard, Oct 28, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    387
    Prodip Saha
    Oct 28, 2005
  7. Amelyan

    Dynamically Created Controls in VS2005 ASP.NET 2.0

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