ButtonClick eventhandler for dynamically loaded UserControl fails to catch event.
-
Hi everyone. I've been handed a Web application that dynamically loads custom UserControls. Upon a useraction, clicking a link to a given "page" (UserControl), I instanciate the control using the Page.LoadControl method, store it to Session["Control"], and add it to PlaceHolder.Controls. This seemed to work out perfectly as the control was maintained on the postback and the state was also maintained. But after I started implementing a button eventhandler I noticed that the event is never caught when the button is clicked and the control refreshes. I'm not that familiar with Asp.Net as I usually work with windows applications and services. Could anyone please point me in the right direction of how to avoid loosing the event in the postback? Best regards! -Larantz-
for those about to code, we salute you
http://www.itverket.noPlease refer to the Forum Guidelines for appropriate posting.
-
Hi everyone. I've been handed a Web application that dynamically loads custom UserControls. Upon a useraction, clicking a link to a given "page" (UserControl), I instanciate the control using the Page.LoadControl method, store it to Session["Control"], and add it to PlaceHolder.Controls. This seemed to work out perfectly as the control was maintained on the postback and the state was also maintained. But after I started implementing a button eventhandler I noticed that the event is never caught when the button is clicked and the control refreshes. I'm not that familiar with Asp.Net as I usually work with windows applications and services. Could anyone please point me in the right direction of how to avoid loosing the event in the postback? Best regards! -Larantz-
for those about to code, we salute you
http://www.itverket.noPlease refer to the Forum Guidelines for appropriate posting.
Hey First things first - check that the event is wired up correctly - think off the top of my head this is done in oninit or some other initialisation function within the page: http://msdn2.microsoft.com/en-us/library/ms743596.aspx If this doesnt fix it then make sure that ISS is using the correct version of .NET. If this doesnt work then google asp.net event not firing as there is loads of help (I had this problem too) - i cant remember how i changed the version of .NET but it is in the properties. Hope this helps Dan