Events for dynamic controls

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
 
B

bruce barker

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)
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top