Showing posts with label InnerHTML vs InnerText. Show all posts
Showing posts with label InnerHTML vs InnerText. Show all posts

Tuesday, June 30, 2009

InnerHTML vs InnerText ASP.Net

InnerHTML renders the html.
InnerText does not render html. It just assigns the value to the specified node.

Sample:

string myContent = "<p>Some HTML markup 3 &lt; 5 text </p>";
myDiv1.InnerText = myContent;
myDiv2.InnerHtml = myContent;

myDiv1 will be rendered as "<p>Some HTML markup 3 &lt; 5 text </p>"
myDiv2 will be rendered as "Some HTML markup 3 < 5 text" in a para.