Reputation: 4602
I have a simple chart in the form of html. I want to persist its appearance for comparison, and wanted to use Session variable for that.
I have used AJAX to pass value of div holding the chart to the server where it is assigned to the Session variable. Unfortunately when I try to render this variable back into the page all special characters are being converted into their html equivalents (like "<" is becoming "<").
How can I preserve original content of the Session variable when converting to html?
I have checked the string value in the controller parameter and it seems to be fine at that point. Was trying to use Javascript replace function but cannot get the starting point which is the valid string.
Upvotes: 2
Views: 1321
Reputation: 9074
CAN USE:
element.InnerHtml = Server.HtmlDecode(yourText);
Follow This Doccument For HtmlDecode
Property.
Upvotes: 0
Reputation: 60503
In your view (If I understood well), you should use
@Html.Raw(<yourVariable>)
which will render "not encoded" html.
Upvotes: 1