HtmlInputCheckBox.Checked Property
Gets or sets a value indicating whether the HtmlInputCheckBox is checked.
[Visual Basic] Public Property Checked As Boolean [C#] public bool Checked {get; set;} [C++] public: __property bool get_Checked(); public: __property void set_Checked(bool); [JScript] public function get Checked() : Boolean; public function set Checked(Boolean);
Property Value
true if the HtmlInputCheckBox control is checked; otherwise, false.
Remarks
Use this property to determine whether the HtmlInputCheckBox control is checked. This property can also be used to programmatically set the state of the HtmlInputCheckBox control.
Example
[Visual Basic, JScript] The following example demonstrates a set of responses to users selecting from a group of HtmlInputCheckBox controls.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <script language="VB" runat=server> Sub SubmitBtn_Click (Source As Object, ByVal E as EventArgs) If (Basketball.Checked = true) Then ' You like basketball End If If (Football.Checked = true) Then ' You like football End If If (Soccer.Checked = true) Then ' You like soccer End If End Sub </script> <body> <form method=post runat=server> Enter Interests: <input id="Basketball" checked type=checkbox runat=server> Basketball <input id="Football" type=checkbox runat=server> Football <input id="Soccer" type=checkbox runat="server"> Soccer <input type=button value="Enter" OnServerClick="SubmitBtn_Click" runat=server> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <script language="JSCRIPT" runat=server> function SubmitBtn_Click (source : Object, e : EventArgs){ if(Basketball.Checked == true){ // You like basketball } if(Football.Checked == true){ // You like football } if(Soccer.Checked == true){ // You like basketball } } </script> <body> <form method=post runat=server> Enter Interests: <input id="Basketball" checked type=checkbox runat=server> Basketball <input id="Football" type=checkbox runat=server> Football <input id="Soccer" type=checkbox runat="server"> Soccer <input type=button value="Enter" OnServerClick="SubmitBtn_Click" runat=server> </form> </body> </html>
[C#, C++] No example is available for C# or C++. To view a Visual Basic or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlInputCheckBox Class | HtmlInputCheckBox Members | System.Web.UI.HtmlControls Namespace