See Also: TextBox Members
In this topic:
The System.Web.UI.WebControls.TextBox server control is an input control that lets the user enter text. By default, the TextBox.TextMode property of the control is set to TextBoxMode.SingleLine, which displays a single-line text box. However, you can also use the System.Web.UI.WebControls.TextBox control to display a multiline text box or a text box that masks user input by changing the value of the TextBox.TextMode property to TextBoxMode.MultiLine or TextBoxMode.Password, respectively. The text displayed in the System.Web.UI.WebControls.TextBox control is specified or determined by using the TextBox.Text property.
The System.Web.UI.WebControls.TextBox control contains several properties that allow you to control the appearance of the control. The display width of the text box, in characters, is determined by its TextBox.Columns property. If the System.Web.UI.WebControls.TextBox control is a multiline text box, the number of rows it displays is determined by the TextBox.Rows property. To display text that wraps within the System.Web.UI.WebControls.TextBox control, set the TextBox.Wrap property to true.
You can also specify how data is entered in the System.Web.UI.WebControls.TextBox control by setting a few properties. To prevent the text displayed in the control from being modified, set the TextBox.ReadOnly property to true. If you want to limit the user input to a specified number of characters, set the TextBox.MaxLength property.
This control can be used to accept user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see Securing Standard Controls, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Introduction to Validating User Input in ASP.NET Web Pages.
<asp:TextBox AccessKey="string" AutoCompleteType="