I'm using ASP.NET and I have a string of HTML in the database.
I want to get that html into a variable on the client.
If I do this:
var x = '@Html.Raw(myModel.FishValue)'
it works fine, because it's essentially doing
var x = '<p>hello!</p>';
however if there are quotes in the html it breaks the page.
My initial guess would be to .Replace the raw string to add escapes to the quotes, however both .ToString()
and .ToHtmlString()
(as Html.Raw returns an IHtmlString) do not produce the same markup as simple Html.Raw()
.
So I'm at a loss of what best to do.