Asp.net pagelifecycle page_loadComplete
In my web app, I load custom controls on the page_loadComplete event. This works great, however, when the button is clicked in the custom control, the click event is never fired. Is this related to the page lifecycle? Do these button (UI) click events happen before the LoadComplete event?
source to share
You need to make sure that the button click event is subscribed again before the event handlers are processed. LoadComplete occurs after control events. For reference, ASP.NET Page Life Cycle Overview provides a pretty nice summary.
Excerpt:
- ...
- Load
- Management events
- LoadComplete
- PreRender
- ...
You also need to make sure that the controls you are loading dynamically are in the same place, so the viewstate and controlstate can be reapplied to the same hierarchy as before postback.
Basically, you need to load all dynamic controls for each postback.
Here's someone with the same problem and solutions for some of them: ASP.NET Dynamic Controls
source to share