title: When are ASP.NET code blocks, e.g., <%= %> executed in the page lifecycle?
body: <p>When I am databinding an entire page, I will do something like this:</p>
  
  <p>Blah blah...</p>
  
  <pre><code>&lt;%# SomeProperty == "GoodBye" ? "See you later" : "Hello" %&gt;
  </code></pre>
  
  <p>And that works beatifully. However, often I will not use databinding for an entire page and write things the "clasic" ASP.NET way. E.g., in the code behind I will have something like:</p>
  
  <pre><code>lblSomeMessage.Text = SomeProperty == "GoodBye" ? "See you later" : "Hello";
  </code></pre>
  
  <p>And then .aspx would have </p>
  
  <pre><code>&lt;asp:label runat="server" id="lblSomeMessage"/&gt;
  </code></pre>
  
  <p>But what I want to do <em>both</em>...sort of. What I would like to do is not use databinding syntax but instead a code block:</p>
  
  <pre><code>&lt;%= SomeProperty == "GoodBye" ? "See you later" : "Hello" %&gt;
  ^^^^
  </code></pre>
  
  <p>Noe the output tag syntax. Now, the question is, when will this tag actually be evaluated? Suppose I don't set the SomeProperty property until the OnPreRender event. Is that too late? In my testing I actually did this:</p>
  
  <pre><code>&lt;%= SomeProperty == "GoodBye" ? + new System.Diagnostics.StackTrace().ToString() : "OH NO!" %&gt;
  </code></pre>
  
  <p>And according to the stacktrace:</p>
  
  <blockquote>
    <p>ASP.webform1_aspx.__Renderform1(HtmlTextWriter __w, Control
    parameterContainer)    at
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children)    at
    System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter
    writer)...</p>
  </blockquote>
  
  <p>It happens during render, which is perfect. But is this guaranteed? Any gotchas to this rule? </p>