javascript - Model data has special characters ( like ' and " )" )which needs to be shown HTML form -
here's requirement i've got string has read database , shown on html ui form. user can perform operations select different string , save database.
here string accept special characters ' , ) well. example , string thing hōnaunau-napo'opo'o) since coming model in corresponding javascript code i've coded access same
var cityname = '@model.cityname'
because of city name containing ' , ) it's invalidating html.
how fix issue ? much.
in c# can use httputility.htmlencode
:
@html.raw(httputility.htmlencode(model.cityname))
special characters converted corresponding html codes
Comments
Post a Comment