Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Getting and Setting a CheckBox Web Server Control Value Programmatically

Getting and Setting a CheckBox Web Server Control Value Programmatically

Visual Studio .NET 2003

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 Web Server Control and Setting the Selection in a List Web Server 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.
    Note   Testing the value of a check box does not tell you if the user changed the value of the control, only if it is selected. For details about how to check for a change in the control, see Responding to User Selection in a CheckBox Web Server Control.

    In the following example, if the check box chkCanWeSendEmail is not selected, the check box chkSendInHTMLFormat is automatically cleared as well.

    ' Visual Basic
    If chkCanWeSendEmail.Checked = false Then
       chkSendInHTMLFormat.Checked = false
    End If
    
    // C#
    if(chkCanWeSendEmail.Checked == false){
       chkSendInHTMLFormat.Checked = false;
    }
    

See Also

CheckBox Class | CheckBoxList Class | Setting ASP.NET Server Control Properties

Show:
© 2015 Microsoft