5.1. Accepting Data in a TextBox Control

The ASP.NET TextBox control accepts keyboard input. As shown in Figure 5-1, the control appears as (depending on the TextMode property) a normal text box, a password variation, or a multiline version.

See Chapter 15 for enhancements to the TextBox control such as a prompting effect and masked input.

Figure 5-1. The TextBox control in single line, password, and multiline versions.

5.1.1. Creating a regular text box

You add an ASP.NET TextBox to your page by dragging it from the Standard group of the Toolbox and dropping it on the page in Design view or Source view. By default, a text box accepts one line of text. You can limit the number of characters the user can enter by opening the properties page (F4) and setting the MaxLength value.

5.1.2. Accepting passwords (somewhat) securely

When you set the TextMode property to Password, the text box hides the password from onlookers by substituting asterisks or bullets. In Figure 5-1, the second text box from the top shows the effect in the browser.

5.1.3. Capturing text with MultiLine mode

When you set the TextMode property to MultiLine, ASP.NET generates an HTML Textarea control. As shown in the bottom text box (refer to Figure 5-1), you set the number of visible lines with the value of ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.