what disadvantages are there to use inner HTML to populate a div tag
consider, all scenarios possible.
Thanku
what disadvantages are there to use inner HTML to populate a div tag consider,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One disadvantage is that you’ll need to escape special characters manually. So, you’ll need to encode characters like >, <, and & (see the Wikipedia article on HTML encoding).
This is pretty trivial to do since there are utilities to do this baked into the .NET libraries, like HttpServerUtility.HtmlEncode, but many people will forget this and not test all the special cases.
Another downside, is that if you’re just populating a
divwith some arbitrary HTML, that means you’re probably building the HTML manually, which can go wrong if you’re just using string concatenation or something primative like that.If you’re doing this client side, it’s much better to just rely on appending elements to the DOM, rather than setting
innerHTML.