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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -