asp.net.ph

Skip Navigation Links

Getting and Setting a CheckBox Control Value Programmatically

Controls You Can Use on Web Forms   ASP.NET Standard Controls   CheckBox and CheckBoxList Controls


You can programmatically read or set the value of a CheckBox Web server control.

NOTE: If you are working with a CheckBoxList control, the procedure for getting and setting the value of a check box is different. For details, see Determining the Selection in a List Control and Setting the Selection in a List Control.

To get or set CheckBox Web server control selection, get or set the CheckBox control’s Checked property. A value of true means the check box is selected.

In the following example, if the check box chkSavePassword is not selected, the check box chkSaveEncrypted is automatically cleared as well, and vice-versa.

if ( chkSavePass.Checked ) {
   chkSaveEncrypted.Checked = true;
else
   chkSaveEncrypted.Checked = false;
}
  C# VB
checkbox2.aspx
Run Sample | View Source
See Also

Responding to User Selection in a CheckBox Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note