title: ASP.NET dynamically generate HTML with server controls
body: <p>When i need to set some value to a Javacript, or any other part of the code, i usually use this:</p>
  
  <pre><code> &lt;script&gt;
      &lt;%# SomeFunction() %&gt; 
   &lt;/script&gt;
  </code></pre>
  
  <p>And this also works for HTML in the document body, like...</p>
  
  <pre><code> &lt;somehtmltag property="&lt;%# SomeFunction2() %&gt;"&gt;
  </code></pre>
  
  <p>And in the code behind i create the function that returns a string, with all the necessary code.</p>
  
  <p>If i add some parameter to a user control like:</p>
  
  <pre><code>&lt;ts:PeopleCard ID="us" runat="server" Visible="&lt;%# IsVisivle() %&gt;" /&gt;
  </code></pre>
  
  <p>It also works, but i try to create the entire user control it does not work.</p>
  
  <pre><code>&lt;%# AddUserControl() %&gt;
  
  Function AddUserControl() as String
      Return "&lt;ts:PeopleCard ID=""us"" runat=""server"" Visible=""true"" /&gt;"
  End Function
  </code></pre>
  
  <p>I understand that this does not work, because this code must be processed by the server to be converted in the actual code. </p>
  
  <p>The final HTML, it shows:</p>
  
  <pre><code>  &lt;ts:PeopleCard ID="us" runat="server" Visible="true" /&gt;
  </code></pre>
  
  <p>when it shouldn't, it should show the processed HTML\css by the server.</p>
  
  <p>So my question is, is it possible to create a control this way? Is it possible to force ASP.NET to "re-process" the page, after I changed its contents in code behind?</p>
  
  <p>I understand there's several other ways to do it. Including, creating the user control in conde behind.</p>
  
  <p>But i need to know, if is possible to do this way...</p>