开发者

render html from database using javascript

开发者 https://www.devze.com 2023-02-10 16:33 出处:网络
I have a dynamic page which has repeating input text fields and is build using Jquery. I use C#.net to get the data to be displayed on the input fields. My question is on how do I handle single Quotes

I have a dynamic page which has repeating input text fields and is build using Jquery. I use C#.net to get the data to be displayed on the input fields. My question is on how do I handle single Quotes and double quotes while rendering the input field. I create jquery string on page render and uses that to render the input fields on the page. But if any of the input fields contains a html tag with double quotes then it screws up the whole pag开发者_JAVA百科e. Let me know I this make sense or need more explanation.


I would return a "safe" string from within the C# that escapes quotes or converts them into html entities.

A quote as a html entity looks like this: ".

An escaped quote has a blackslash in front of it like so: \".

You shouldn't rely on Javascript to do this, let your CMS do the work for you!

0

精彩评论

暂无评论...
验证码 换一张
取 消