TextBox Web Server Control

Creates single-line and multiline text boxes.

<asp:TextBox id="value"
     AutoPostBack="True|False"
     Columns="characters"
     MaxLength="characters"
     Rows="rows"
     Text="text"
     TextMode="SingleLine | MultiLine | Password"
     Wrap="True|False"
     OnTextChanged="OnTextChangedMethod"
     runat="server"/>

Remarks

The TextBox server control is an input control that lets the user enter text. By default, the TextMode property is set to SingleLine, which creates a text box with only one line. You can also set the property to MultiLine or Password. MultiLine creates a text box with more than one line. Password creates a single-line text box that masks the value entered by the user.

The display width of the text box is determined by its Columns property. If the text box is a multiline text box, the display height is determined by the Rows property.

Use the Text property to determine the contents of the TextBox control. You can limit the number of characters that can be entered in the control by setting the MaxLength property. Set the Wrap property to true to specify that the contents of the cell should automatically continue on the next line when the end of the text box is reached.

For detailed information on the TextBox Web server control's properties and events, see the TextBox Class documentation.

Example

The following shows a sample declaration for a TextBox control in an .aspx file. The control is multiline text box that displays a maximum of ten lines. The text is formatted in Arial font if the browser supports fonts for controls. The method txtLogin_Changed is bound to the control's TextChanged method.

<asp:TextBox runat=server
     id="txtLogin"
     Text=""
     Font_Face="Arial" Font_Size="3"
     BackColor="lightblue"
     TextMode="MultiLine"
     Height="10"
     OnTextChanged="txtLogin_Changed"/>

See Also

Web Server Controls | TextBox Class