JavaScript Editor Javascript validator     Javascripts

Main Page


Previous Section Next Section

5.3 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, and so on

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

MaxLength

Int32

x

x

0, 1, 2, and so on

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.

Rows

Int32

x

x

0, 1, 2, and so on

Number of lines of text in a multiline text box. The default is 0, which imposes no limit on the number of lines.

Text

String

x

x

 

Content of the TextBox.

TextMode

TextBoxMode

x

x

SingleLine, MultiLine, Password

SingleLine, the default value, displays a single line of text.

MultiLine allows multiple lines of text and displays a vertical scroll bar, even for Rows = 1. The text wraps automatically to fit the width of the box. The Enter key enters a CR/LF. The mouse or tab key causes focus to leave the box and initiates postback if AutoPostBack is true.

Password displays content in asterisks, then clears the text box on posting.

The value is not case-sensitive.

Wrap

Boolean

x

x

true, false

Indicates if text within a multiline text box should wrap. If false, then the text box will have a horizontal scrollbar. Default is true.

The TextBox control raises the TextChanged event, which is handled by the OnTextChanged event handler. This event handler is passed a standard EventArgs argument.

    Previous Section Next Section


    JavaScript Editor Javascript validator     Javascripts 
    R7



    ©