Reputation: 482
I am trying to do something like this:
<script>
var comment = "<%=Server.HTMLEncode(rc("comment"))%>";
</script>
What I tried and it didn't work:
var comment = "<%=Server.HTMLEncode(rc('comment'))%>";
var comment = "<%=Server.HTMLEncode(rc("""comment"""))%>";
var comment = "<%=Server.HTMLEncode(rc(" & chr(34) & "comment" & chr(34) & "))%>";
Also var comment = '<%=Server.HTMLEncode(rc("comment"))%>';
doesn't work because the string that is returned might have ' in it and so the sentence breaks in the middle.
Upvotes: 1
Views: 413
Reputation: 13068
Try something like:
var comment = "<%= Replace(Server.HTMLEncode(rc("comment")), """", "\""") %>";
This function replaces "
with \"
Upvotes: 2