andre72
asked on
Get HTML string from code behind
Hi,
I generate some HTML code from code behind I like to use at client side.
The strings are very complex (full HTML sides) and if I return as raw I get errors and my JavaScript don't work any more (destroyed by the return value).
So I need something like HttpUtility.HtmlEncode before I return it to client.
This works fine but now I need to convert it back as the HTML tags now destroyed and also the layout.
Is there a other function that may work than HttpUtility.HtmlEncode JavaScript can handle native?
Thanks
Andre
I generate some HTML code from code behind I like to use at client side.
The strings are very complex (full HTML sides) and if I return as raw I get errors and my JavaScript don't work any more (destroyed by the return value).
So I need something like HttpUtility.HtmlEncode before I return it to client.
This works fine but now I need to convert it back as the HTML tags now destroyed and also the layout.
Is there a other function that may work than HttpUtility.HtmlEncode JavaScript can handle native?
Thanks
Andre
You can use the javascript functions escape() and unescape() in most cases.
ASKER
A sample for <html>
After HTMLEncode:
<html>
Client side:
unescape() returns <html>
escape() returns %26lt%3Bhtml%26gt%3B
After HTMLEncode:
<html>
Client side:
unescape() returns <html>
escape() returns %26lt%3Bhtml%26gt%3B
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks this looks much better ...
I still can't understand why special chars are destroyed - do you have an idea for?
I still can't understand why special chars are destroyed - do you have an idea for?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What do you mean destroyed?
ASKER
I'm sorry the special char problem was a StreamReader issue and not a de-/encoding problem
ASKER
Thanks for your support the JQuery and the HTMLDecoder Custom Class both works fine!