Events for dynamic controls

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

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
 
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)
 
Back
Top