I am attempting to access a static piece of HTML from JavaScript. Here is what I am doing:
In _Header.cshtml:
@{
string HTMLContent = @Server.HtmlDecode("<div>Hello World</div>");
}
<script type="text/javascript">
var StaticHTML = @HTMLContent;
</script>
However, I am getting the following error:
Uncaught SyntaxError: Unexpected token &
When I step through it does appear that the HTMLContent variable is being printed in JavaScript as if it were Unencoded.
What am I missing here?