render html from database using javascript
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!
精彩评论