Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't load everything in the page event in control b, just put a method on control b to be called. Then add an event to control a which the page consumes, when the event is raised, call the load method on control b.</p> <p>Edit: SampleCode</p> <p>Ok so for example, create</p> <ul> <li>a ASPX page</li> <li>2x user controls</li> </ul> <p>Put both user controls into the aspx page.</p> <pre><code> &lt;cc:control1 runat="server" id="control_one" /&gt; &lt;cc:control2 runat="server" id="control_two" /&gt; </code></pre> <p>Then in <strong>control 1</strong>, create a delegate and event.</p> <pre><code> public delegate void MyCustomEvent (EventArgs args); public event MyCustomEvent MyEvent; protected void Page_Load(object sender, EventArgs e) { MyEvent(e); } </code></pre> <p>So I have the event raised on page load. So you would have your logic in there thats required, when your done, calls MyEvent event.</p> <p>In the page you want to add a handler for that event so when it's called you can do something with it.</p> <pre><code> protected override void OnInit(EventArgs e) { control_one.MyEvent += new WebUserControl1.MyCustomEvent(control_one_MyEvent); base.OnInit(e); } void control_one_MyEvent(EventArgs args) { control_two.MyCustomLoad(); } </code></pre> <p>So when the page is initialized I add the event handler. In the event handler I call a custom method on the second control to load stuff.</p> <p>Then in the second control I have:</p> <pre><code> public void MyCustomLoad() { //Stuff only loaded when event is raised and calls this method. } </code></pre> <p>So this allows control 1 to load something, say it's done, when the page knows it's done, it can tell control 2 to do something.</p> <p>Edit: After discussing this with a friend I'll explain what I mean by controlling the order.</p> <p>You cannot control the order of page-life-cycle events. i.e: You can't have Control A, run through all it's page-life-cycle events, then once it's done, have Control B run through all it's page-life-cycle events. </p> <p>If you do-away with the page life cycle, you can do a degree, as my example above shows, create a way of controlling the order in which the controls are rendered. By raising an event(s) at certain points when Control A is finished, you can tell Control B to do something.</p> <p>The intermediate between the two controls is the page which handles the events raised by Control A which calls a method on Control B. You <em>(well you can hack around to do it)</em> can't specifically make Control A tell Control B to do something because that creates a direct dependency between the two controls which is bad.</p>
    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