Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.loadcomplete.aspx" rel="noreferrer"><strong><code>Page_LoadComplete</code></strong></a> is the event that is raised after all controls have been loaded</p> <p>Remember that the <code>Init</code> event is first triggered by all child controls, and just when all controls have been initialized, the <code>Init</code> event of the page is raised. The <code>Load</code> event works the other way around, the page first raises the <code>Load</code> event and then each child control raises its own <code>Load</code> event. At the end the <code>LoadComplete</code> is raised. <strong>Note that this is true only when the controls are created at design time</strong>, when the controls are created dynamically they (sadly) do not follow this approach strictly.</p> <p>From MSDN:</p> <blockquote> <p>If controls are created dynamically at run time or declaratively within templates of data-bound controls, their events are initially not synchronized with those of other controls on the page. For example, <strong>for a control that is added at run time, the Init and Load events might occur much later in the page life cycle</strong> than the same events for controls created declaratively. Therefore, from the time that they are instantiated, dynamically added controls and controls in templates raise their events one after the other until they have caught up to the event during which it was added to the Controls collection.</p> </blockquote> <p>Take a look:</p> <p>(source: <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms178472.aspx</a>)</p> <p><img src="https://i.stack.imgur.com/jafWI.png" alt="enter image description here"></p> <h2>Edit 1</h2> <p>In order to fulfill all your requirements:</p> <blockquote> <p>i need a way to run code after all Page_Load events have fired, but before any postback events (e.g. Click events) have fired:</p> </blockquote> <p>I think the easiest way is to declare a custom event in the User Control and fire it after the control has been loaded, then jus subscribe to that event in your ASPX</p> <h3>User Control</h3> <pre><code> public event Action LoadCompleted = delegate { }; protected void Page_Load(object sender, EventArgs e) { this.LoadCompleted(); } </code></pre> <h3>ASPX page</h3> <pre><code> protected void Page_Load(object sender, EventArgs e) { this.myUserControl.LoadCompleted += () =&gt; { // do somethign interesting this.lblMessage.Text = DateTime.Now.ToString(); }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload