title: If statements in aspx files
body: <p>I have some code that essentially looks like this:</p>
  
  <pre class="lang-asp.net prettyprint-override"><code>&lt;div&gt;
      &lt;% if(Something) { %&gt;
          &lt;div id="someUniqueMarkup"&gt;
              This markup should not be output if Something==true.
  
              &lt;units:MyUserControl runat="server"/&gt;
          &lt;/div&gt;
      &lt;% }
      else { %&gt;
          &lt;units:MyUserControl runat="server" /&gt;
      &lt;% } %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Depending on <code>Something</code>, one of them is hidden, and that is fine. But if I set break points in the user control, I notice it's being loaded twice (once for each of the controls above) and all it's logic is being run twice. I could of course control this with placeholders or multiviews, but the same thing seems to apply - <code>OnLoad</code>/<code>Page_Load</code> etc is run once for each control that is actually on the page.</p>
  
  <p><strong>EDIT:</strong>
  The reason why im showing/hiding this is because I need to include some markup around the control if <code>Something == true</code>. I could wrap the "unique markup" itself in if-else before and after the control, but that just seems dirty for something that really should be as simple as I've imagined above. The user control itself should be exactly the same in both scenarios, sorry for the confusing property it had.</p>
  
  <p>Is it just me, or is this just a really unintuitive interface? And is it actually possible to not load/execute a user control at all as long as it's on the page?</p>