How do you retain markup language in an div.html() method
<p>What i want is allow users to be able to write markup language in an div element
So if the was a script as such, so writemarkup = .....</p>

<pre><code>&lt;script type="text/magicTemplate" id="scriptId"&gt;
var div = document.createElement("div"),
    span = document.createElement("span");

span.textContent = data.foo;

div.appendChild(span);

return div;
&lt;/script&gt;
</code></pre>

<p>and i need to write this in the div.html(writemarkup);</p>

<p>I have tried to htmlencode all the text serverside and then write it into the .html() but the script tags go missing because the .html() actually decodes everything</p>

<pre><code>Dim messageUrlEncoded As String = System.Web.HttpContext.Current.Server.HtmlEncode(message)
</code></pre>

<p>The text is originally coming from a text area by the way</p>

<p>This is what im doing to write out the message</p>

<pre><code>    var divMessage = $("&lt;div/&gt;");
    $(divMessageOuter).append(divMessage);
    $(divMessage).attr("class", "divmessage");
    $(divMessage).html(message);
</code></pre>

<p>The output is:</p>

<pre><code>&lt;script&amp;nbsp;type="text/magicTemplate"&amp;nbsp;id="scriptId"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;var&amp;nbsp;div&amp;nbsp;=&amp;nbsp;document.createElement("div"),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;span&amp;nbsp;=&amp;nbsp;document.createElement("span");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;span.textContent&amp;nbsp;=&amp;nbsp;data.foo;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;div.appendChild(span);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;return&amp;nbsp;div;&lt;br /&gt;&lt;/script&gt;
</code></pre>
