Link to home
Start Free TrialLog in
Avatar of andre72
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
Avatar of DigitalTyrant
DigitalTyrant

You can use the javascript functions escape() and unescape() in most cases.
Avatar of andre72

ASKER

A sample for <html>
After HTMLEncode:
&lt;html&gt;

Client side:
unescape() returns &lt;html&gt;
escape() returns %26lt%3Bhtml%26gt%3B
ASKER CERTIFIED SOLUTION
Avatar of DigitalTyrant
DigitalTyrant

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andre72

ASKER

Thanks this looks much better ...
I still can't understand why special chars are destroyed - do you have an idea for?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What do you mean destroyed?  
Avatar of andre72

ASKER

I'm sorry the special char problem was a StreamReader issue and not a de-/encoding problem
Avatar of andre72

ASKER

Thanks for your support the JQuery and the HTMLDecoder Custom Class both works fine!