ASP.NET Pack Programmer's Guide
PasswordBox

The PasswordBox control represents a text input control with password protection.

Server side

Getting and setting the control's text

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

Customizing the control

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.

The MaskChar allows custom characters to be used to hide the user's input. You can show or hide the reveal password button by setting the ShowButton property.

Events

The following events are exposed by the PasswordBox 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 passwordBox = $find("PasswordBox1");
var passwordBox = $find("<%= PasswordBox1.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

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

Events

The following client-side events are exposed by the PasswordBox 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 control's 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.