HtmlContainerControl::InnerText Property
Gets or sets the text between the opening and closing tags of the specified HTML server control.
Assembly: System.Web (in System.Web.dll)
| Exception | Condition |
|---|---|
| HttpException | There is more than one HTML server control. - or - The HTML server control is not a System.Web.UI::LiteralControl or a System.Web.UI::DataBoundLiteralControl. |
Use the InnerText property to programmatically modify the text between the opening and closing tags of an HTML server control.
Unlike the InnerHtml property, the InnerText property automatically encodes special characters to and from HTML entities. HTML entities allow you to display special characters, such as the < character, that a browser would ordinarily interpret as having special meaning. The < character would be interpreted as the start of a tag and is not displayed on the page. To display the < character, you would need to use the entity <.
For example, if the InnerText property is set to "<b> Hello </b>", the < and > symbols are converted to < and >, respectively. The rendered output would be: < b > Hello < /b >. The < and > entities would indicate to the browser that these characters are to be displayed on the page. The browser will not detect the <b> tags and display the text in a bold font. The text displayed on the page is: <b> Hello </b>.
To prevent automatic HTML encoding and decoding, use the InnerHtml property.
Note |
|---|
If there are no child controls, the InnerHtml property contains the value String::Empty. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note