Export (0) Print
Expand All

TextBox::Text Property

Gets or sets the text content of the TextBox control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[BindableAttribute(true, BindingDirection::TwoWay)]
[PersistenceModeAttribute(PersistenceMode::EncodedInnerDefaultProperty)]
public:
virtual property String^ Text {
	String^ get ();
	void set (String^ value);
}
<asp:TextBox Text="String" />

Property Value

Type: System::String
The text displayed in the TextBox control. The default is an empty string ("").

Implements

ITextControl::Text

Use the Text property to specify or determine the text displayed in the TextBox control. To limit the number of characters accepted by the control, set the MaxLength property. If you want to prevent the text from being modified, set the ReadOnly property.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

When the text box is rendered, the contents of this property are HTML-encoded. For example, if you set this property to "<b>Test</b>", the browser will display "<b>Test</b>", not "Test" in bold.

The following code example demonstrates how to use the TextBox control to get user input. When the user clicks the Add button, the sum of the values entered in the text boxes is displayed.

Security noteSecurity Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft