4

I have the following function which I pass in a value, but this value is coming from the database. However I get the following javascript when doing the following:

showrootcausedetails('showrootcause',true,'<%# eval("Root Cause Analysis").ToString() %>')

I know I have to escape the characters, but How can I do that without knowing what is in the actual string?

Thanks,

Jacob

1 Answer 1

6

Call Server.JavaScriptStringEncode.

Sign up to request clarification or add additional context in comments.

3 Comments

+1 - OP might be on less than .NET 4.0 though. There's some solutions to that here - stackoverflow.com/questions/2920752/…
Do I need to reference something before using that function ?
I am getting the the same error text for this: var setScript = "<script></script>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.