Postback problem with usercontrol in usercontrol

M

Mark van Bree

Hi,

Working with ASP.Net 2.0 with VS2005 and VB.

I have a problem with a master usercontrol on which I dynamically create a
usercontrol in a placeholder. The usercontrol displays fine, but the onclick
event of a button on the dynamically loaded usercontrol does not fire.

How can I get the onclick event to run the code assigned to the button in
codebehind?


Thanks in advance,

Mark
 
C

CaffieneRush

If the control is dynamically created then you will need to dynamically
recreate it on the postback for it's events to be fired even if you are
no longer interested in displaying it again later.
You can choose not display the control by removing it from the page
control heirarchy within the Click handler.
Else if you do not recreate the control on postback then it's events
would be silently lost as you discovered.

Also, when you're recreating the control (button in this case), you
will need to recreate it exactly so that the framework knows which
event matches up with which control i.e. IDs must be same the first
time and subsequnt postbacks.

Regards,
Andy
 

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

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top