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?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Kenton Smeltzer

    ASP.NET Events and dynamic controls

    Kenton Smeltzer, Oct 22, 2003, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    285
    Kenton Smeltzer
    Oct 22, 2003
  2. hybrid

    Dynamic controls & events

    hybrid, Oct 24, 2003, in forum: Microsoft ASP .NET
    Replies:
    1
    Views:
    187
    William F. Robertson, Jr.
    Oct 24, 2003
  3. Michael Ramey

    Dynamic Controls and their events

    Michael Ramey, Feb 5, 2004, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    230
    Michael Ramey
    Feb 5, 2004
  4. Replies:
    5
    Views:
    1,092
  5. Guest

    order of events - dynamic checkbox events

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

    Dynamic Controls created by Dynamic Controls

    Ronald, Jan 16, 2006, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    480
    Robbe Morris [C# MVP]
    Jan 17, 2006
  7. newbye
    Replies:
    0
    Views:
    341
    newbye
    Jul 6, 2006
  8. SevDer
    Replies:
    2
    Views:
    1,662
    Walter Wang [MSFT]
    Nov 13, 2007
Loading...