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?

+2


source to share


3 answers


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

+3


source


Actually what happens to your situation when you click the button, before raising the event, the Event LoadCoplete event is fired first in the page lifecycle, and the same control is created again, and that's where your event is lost.



+1


source


Event handling on an ASP.NET page occurs after validation and before the rendering phase. The verification phase is performed after loading.

LoadComplete occurs after the Control events and before the RreRender event.

0


source







All Articles