ASP.NET Pack Programmer's Guide
CheckBox

The CheckBox control can act as a two- or tristate checkbox or radiobutton.

Server side

Getting and setting the control's state

Use the CheckBox.Checked or CheckBox.State properties to get or set the control's state.

Customizing the control

The CheckBox control can represent either a checkbox or a radiobutton control depending on the value of the DisplayType property. Use the TriState property to specify whether the control supports indeterminate state. Use the GroupName property to specify mutually exclusive controls.

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

By setting the Label and LabelPosition properties you can specify a caption for the control.

Events

The following events are exposed by the CheckBox class.

Event

Event arguments

Description

CheckedChanged

ValueChangedEventArgs<CheckState>

Raised when the state of the control changes.

Client side

Getting a reference to the control

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

JavaScript  Copy Code
var checkBox = $find("CheckBox1");
var checkBox = $find("<%= CheckBox1.ClientID %>");

Getting and setting the control's state

Use the get_state and set_state or get_checked and set_checked methods to get or set the control's state.

JavaScript  Copy Code

checkBox.set_checked(true);
alert(checkBox.get_state());

Events

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

Event

Event arguments

Script property

Description

stateChanging

ValidationStateChangedEventArgs

StateChangingScript

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

stateChanged

ValidationStateChangedEventArgs

StateChangedScript

Raised when a control's state has changed.

controlLoaded

-

ControlLoadedScript

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