Gets or sets the text between the opening and closing tags of the specified HTML server control.
Namespace:
System.Web.UI.HtmlControls
Assembly:
System.Web (in System.Web.dll)
Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public Overridable Property InnerText As String
Dim instance As HtmlContainerControl
Dim value As String
value = instance.InnerText
instance.InnerText = value
[BrowsableAttribute(false)]
public virtual string InnerText { get; set; }
[BrowsableAttribute(false)]
public:
virtual property String^ InnerText {
String^ get ();
void set (String^ value);
}
public function get InnerText () : String
public function set InnerText (value : String)
<asp:HtmlContainerControl InnerText="String" />
Property Value
Type:
System..::.StringThe text between the opening and closing tags of an HTML server control.
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.
The following code example demonstrates the HTML encoding service available through the InnerText property.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Message.InnerText = "To make text bold, use the <b> tag."
End Sub
</script>
<html >
<head id="Head2" runat="server">
<title>HtmlContainerControl Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b><span id="Message" runat="server"></span></b>
</div>
</form>
</body>
</html>
<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
Message.InnerText = "To make text bold, use the <b> tag.";
}
</script>
<html >
<head runat="server">
<title>HtmlContainerControl Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b><span id="Message" runat="server"></span></b>
</div>
</form>
</body>
</html>
<%@ Page Language="JScript" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
function Page_Load(Src: Object, E: EventArgs)
{
Message.InnerText = "To make text bold, use the <b> tag."
}
</script>
<html >
<head id="Head1" runat="server">
<title>HtmlContainerControl Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b><span id="Message" runat="server"></span></b>
</div>
</form>
</body>
</html>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Reference