TextBox Control

The TextBox control can be used for both user input and read-only text display. It can be configured to be any one of the following: single-line, multiline, or to accept passwords. If multiline, it automatically wraps, unless the Wrap property is set to false. The text it contains can exceed the length of the control displayed on the page.

Table 5-2 lists many of the common properties specific to the TextBox control. If any of these attributes are omitted from the control, then the default value will apply.

Table 5-2. Some properties specific to the TextBox control

Name

Type

Get

Set

Values

Description

AutoPostBack

Boolean

x

x

true, false

Determines if automatic postback to server will occur if user changes contents of control. If false, postback to server will not occur until the page is posted, either by a button or another control with AutoPostBack set to true. Default is false.

Columns

Int32

x

x

0, 1, 2, etc.

Width of the text box in characters. Default is 0.

MaxLength

Int32

x

x

0, 1, 2, etc.

Maximum number of characters allowed.

If MaxLength is greater than Columns, then only a portion of the string will display without using the home, end, or arrow keys.

Its default value is 0, which does not impose a limit on the number of characters entered into the text box.

ReadOnly

Boolean

x

x

true, false

If true, content cannot be changed by user. Default is false, meaning content can still be changed programmatically.

Get Programming ASP .NET 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.