title: Displaying html that has aspx code embedded into it, in a view
body: <p>I have html strings stored in a database. These are labels and input fields but they also have aspx code in them. You know the nasty &lt;%=%&gt; stuff. In the view I use HtmlDecode(databaseString) on it and it renders the pure html but treats the aspx code as strings. Is there anyway that in the view this can be treated as aspx code?</p>
  <p>This is basically a dynamic input form generator where we can define fields and then structure them into different forms for users to fill out. This helps us make it data driven instead of changing the code each time.</p>
  <p>View example:</p>
  <pre><code>&lt;% var incidentFields = (List&lt;string&gt;)ViewData[&quot;InputFields&quot;]; %&gt;
  
  &lt;%foreach(var fields in incidentFields){%&gt;
  
     &lt;%=System.Web.HttpUtility.HtmlDecode(fields) %&gt;
  
  &lt;%}%&gt;
  </code></pre>
  <p>The result:</p>
  <p><a href="https://i.stack.imgur.com/dHmDm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dHmDm.png" alt="enter image description here" /></a></p>