How do I escape html

  • Thread starter Thread starter Danny Ni
  • Start date Start date
D

Danny Ni

Hi,

I have the following snippet in a web form:

<a href="#" onclick="javascript:SelectGame('<%# Eval("GameID") %>','<%#
Eval("Title") %>' )">Select</a>

The GameID and Title are frrom SQL database, sometimes Title could contains
apostrophe ( ' ) or quote ( " ) and triggers "unterminated string" errors by
browser. What should I do to prevent the errors?

TIA
 
Hi,

I have the following snippet in a web form:

<a href="#" onclick="javascript:SelectGame('<%# Eval("GameID") %>','<%#
Eval("Title") %>' )">Select</a>

The GameID and Title are frrom SQL database, sometimes Title could contains
apostrophe ( ' ) or quote ( " ) and triggers "unterminated string" errorsby
browser. What should I do to prevent the errors?

TIA

you can use HttpServer.HtmlEncode
usually you access it by using Page.Server.HtmlEncode from the code
behind
 
Back
Top