TextBox Web Server Control Overview

The TextBox Web server control provides a way for users to type information into a Web Forms page, including text, numbers, and dates. You can configure the TextBox Web server control in several ways, as described in the following table.

Configuration Description

Single-line

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

Password

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

Security noteSecurity Note
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.

Multiline

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

Security noteSecurity Note

User input in a Web Forms page can include potentially malicious client script. By default, the Web Forms page validates that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

TextBox Events

The TextBox control raises a TextChanged event when the user leaves the control. By default, the event is not raised immediately; instead, it is raised on the server when the Web Forms page is submitted. However, you can specify that the TextBox control should submit the page to the server as soon as the user leaves the field.

The TextBox Web server control does not raise an event each time the user enters a keystroke, only when the user leaves the control. You can have the TextBox control raise client-side events that you handle in client script, which can be useful for responding to individual keystrokes. For details, see Programming ASP.NET Web Pages with Client Script.

TextBox Captions

You can use Label controls to create captions for TextBox controls. The caption can define an access key that users can press to navigate to the TextBox control. For details, see How to: Use Label Web Server Controls as Captions.

Auto-Completion in Text Boxes

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:

  • Disable auto-completion. If you do not want the browser to offer auto-completion for a text box, you can disable it.

  • Specify a vCard value to use as the auto-completion value for the field. The browser must support the vCard schema.

See Also

Tasks

How to: Get and Set Values in TextBox Web Server Controls