What I am trying to do is implement a "preview" function that displays all of the html typed within a textarea onto a webpage with HTML intact. I am using the viewstate to preserve the contents of the textarea. However, I find that doing this replaces all "<" with "<", ">" with ">". As a result, the preview does not render any HTML.
It appears that viewstate with asp.net automatically converts the chars, perhaps as insurance to "sterilize" malicious script. Can someone confirm this?
Is there a way to prevent it from converting the carat characters for the viewState preservation? Or is it a fact of life that I'll need to manually convert them back?
Thanks,
walla118Thanks niceguy.
I just realized that HtmlDecode would work for my purposes. And your idea about using javascript to display preview might be a good way to go!
Thanks again.
Hi walla118,
Have you tried using:
HttpContext.Current.Server.HtmlEncode
HttpContext.Current.Server.HtmlDecode
These may help...?
I found that it is easier to open a pop-up using javascript for a "preview" rather than doing it server side...just a thought.
Hope this helps!
Jason
0 comments:
Post a Comment