TextBox control

The TextBox control provides a way for users to type information into an ASP.NET page, including text, numbers, and dates.

To add a TextBox control to a page

  1. Drag the TextBox control from the Toolbox task pane to your page.

  2. Set properties for the control in the Tag Properties task pane.

Common TextBox Properties




Specifies the default text displayed in the TextBox.


Specifies the maximum number of characters a user can type in the TextBox. The MaxLength property has no effect in a multiline text box.

You can configure the TextBox control in several ways by setting the TextMode property.

TextBox control TextMode property settings

TextMode setting



Users type information in a single line. You can optionally limit the number of characters that the control accepts.


Like a single-line TextBox control, but the characters users type are masked with asterisks (*) to hide them.


Users type information in a box that displays multiple lines and allows text wrapping.


Using a TextBox control set for passwords can help ensure that other people will not be able to determine a user's password if they observe the user entering it. However, the password text entered is not encrypted in any way, and you should protect it as you would any other confidential data. For example, for maximum security when posting a form with a password in it, you might use Secure Sockets Layer (SSL) and encryption.

For a full description of all TextBox control properties, see TextBox Properties in the MSDN library.

Many browsers support an auto-completion feature that helps users fill information into text boxes based on values the users have entered previously. The exact behavior of auto-completion depends on the browser. In general, browsers store values based on the text box's name attribute; any text box with the same name, even on a different page, will offer the same values to the user. Some browsers also support a vCard schema, which allows users to create a profile in the browser with predefined values for first name, last name, telephone number, e-mail address, and so on.

The TextBox control supports an AutoCompleteType property that provides you with these options for controlling how the browser works with auto-completion: Set the AutoCompleteType property to None if you do not want the browser to offer auto-completion for a text box, you can disable it.