Events for dynamic controls

Discussion in 'Microsoft ASP .NET' started by Tom, Dec 12, 2008.

  1. Tom

    Tom Guest

    I have a user control that is presented in a listview. I'm creating
    controls during load and overriding Render. My problem is:
    If I am creating a new Button for each instance of this control - how can I
    trap the click event?

    I have a panel with the button in the aspx file. The button has onclick
    defined and when I show the control during the Render I do
    Panel.RenderControl(htmlWriter). When I click the button the debugger does
    not break in the click event.

    Thanks..>Tom
     
    Tom, Dec 12, 2008
    #1
    1. Advertisements

  2. Tom

    bruce barker Guest

    for control to take part of event handling they must be part of the
    control tree, have the same id (as must its parents) on postback as
    original render, created before onload, and have the event hookup done
    by on onload.

    you code does not do all of this, so you need to implement your own
    event handling in the user control. see docs on building controls and
    implementing event handling.

    -- bruce (sqlwork.com)

    Tom wrote:
    > I have a user control that is presented in a listview. I'm creating
    > controls during load and overriding Render. My problem is:
    > If I am creating a new Button for each instance of this control - how can I
    > trap the click event?
    >
    > I have a panel with the button in the aspx file. The button has onclick
    > defined and when I show the control during the Render I do
    > Panel.RenderControl(htmlWriter). When I click the button the debugger does
    > not break in the click event.
    >
    > Thanks..>Tom
    >
    >
     
    bruce barker, Dec 12, 2008
    #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. Replies:
    5
    Views:
    919
  2. Guest

    order of events - dynamic checkbox events

    Guest, Aug 17, 2005, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    229
    Guest
    Aug 17, 2005
  3. Ronald

    Dynamic Controls created by Dynamic Controls

    Ronald, Jan 16, 2006, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    286
    Robbe Morris [C# MVP]
    Jan 17, 2006
  4. newbye
    Replies:
    0
    Views:
    243
    newbye
    Jul 6, 2006
  5. SevDer
    Replies:
    2
    Views:
    1,280
    Walter Wang [MSFT]
    Nov 13, 2007
Loading...

Share This Page