HtmlContainerControl.InnerHtml Property
Assembly: System.Web (in system.web.dll)
/** @property */ public String get_InnerHtml () /** @property */ public void set_InnerHtml (String value)
public function get InnerHtml () : String public function set InnerHtml (value : String)
Not applicable.
Property Value
The HTML content between opening and closing tags of an HTML server control.| Exception type | Condition |
|---|---|
| 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 InnerHtml property to programmatically modify the contents between the opening and closing tags of an HTML server control.
The InnerHtml property does not automatically encode 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 InnerHtml property is set to "<b> Hello </b>", the < and > characters are not converted to < and >, respectively. The rendered output would still be: <b> Hello </b>. The browser will detect the <b> tags and display the text, Hello, in a bold font.
Caution: |
|---|
| Because the text is not HTML encoded, it possible to embed script within HTML tags in the text. If this property is set dynamically using user input, be sure to validate the value to reduce security vulnerabilities. For more information, see Security and User Input. |
To provide automatic HTML encoding and decoding, use the InnerText property.
Note: |
|---|
| If there are no child controls, the InnerHtml property contains the value String.Empty. |
Caution: