ASP.NET Pack Programmer's Guide
TextBox

The TextBox control represents a customizable text input control.

Server side

Getting and setting the control's text

Use the TextBox.Text or TextBox.Value properties to get or set the control's text.

Customizing the control

The TextBox control can represent either a single or multiline text input control depending on the value of the Rows property.

By using the MaxLength property you can specify the maximum number of chars allowed and by setting the AllowEmptyInput property you can define whether or not empty string values are considered valid for the control.

Adjust the interaction with the control by setting the SubmitOnEnter and AutoPostBack properties according to your needs.

By setting the EmptyText property you can display a hint to the user, and by setting the Label and LabelPosition properties you can specify a caption for the control.

Events

The following events are exposed by the TextBox class.

Event

Event arguments

Description

ValueChanged

ValueChangedEventArgs<String>

Raised when the control's value has changed.

Client side

Getting a reference to the control

You can access the control on the client side by its ClientID.

JavaScript  Copy Code

var textBox = $find("TextBox1");
var textBox = $find("<%= TextBox1.ClientID %>");

Getting and setting the control's text

Use the get_text and set_text or get_value and set_value methods to get or set the control's text.

JavaScript  Copy Code

textBox.set_text('test');
alert(textBox.get_value());

Events

The following client-side events are exposed by the TextBox class.

Event

Event arguments

Script property

Description

valueChanging

ValueChangingEventArgs

ValueChangingScript

Raised when a control's value is about to be changed.

valueChanged

ValueChangedEventArgs

ValueChangedScript

Raised when a control's value has changed.

validate

ValueChangingEventArgs

ValidateScript

Raised when the control's value is validating.

valueInvalid

ValueChangedEventArgs

ValueInvalidScript

Raised when the date input is invalid.

validationStateChanged

ValidationStateChangedEventArgs

ValidationStateChangedScript

Raised when the validation state of the control changes.

controlLoaded

-

ControlLoadedScript

Raised just after the control has finished loading and is ready for interaction.