Is there an after Page_Load event in ASP.net

前端 未结 2 1651
野趣味
野趣味 2020-12-13 02:51

Is there an event that is triggered after all Page_Load events have completed?

How can i have more than one Page_Load

2条回答
  •  猫巷女王i
    2020-12-13 03:09

    It seems that there really is no way to reliably get your code to execute between the time when all (statically declared, see Jupaols comment about dynamically added) controls are loaded and the time when their postback events are raised.

    I even went so far as to disassemble the Page class using reflector and as far as I could tell, the page isn't calling any methods that you could tap into between these times.

    So for the general case it seems like your just out of luck.

    But your statement

    then i begin to access my UserControl1 control before it is ready

    is questionable. By the time the Page_Load method is called, the viewstate and control state have been set on all controls (at least the statically declared ones). So unless you have some more state initialization going on in the OnLoad method of a control, the control is ready to be tinkered with. If you DO have something going on in OnLoad, then why not do the tinkering there?

提交回复
热议问题