This documentation is archived and is not being maintained.

HtmlInputCheckBox.Checked Property

Gets or sets a value indicating whether the HtmlInputCheckBox is selected.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

public bool Checked { get; set; }
/** @property */
public boolean get_Checked ()

/** @property */
public void set_Checked (boolean value)

public function get Checked () : boolean

public function set Checked (value : boolean)

Property Value

true if the HtmlInputCheckBox control is selected; otherwise, false.

Use this property to determine whether the HtmlInputCheckBox control is selected. This property can also be used to programmatically set the state of the HtmlInputCheckBox control.

The following code example demonstrates a set of responses to users selecting from a group of HtmlInputCheckBox controls.

<%@ Page Language="C#" %>

<html >
  <script language="C#" runat=server>

    protected void SubmitBtn_Click(object sender, EventArgs e)
      if (Basketball.Checked)
        // You like basketball
      if (Football.Checked)
        // You like football
      if (Soccer.Checked)
        // You like soccer
       <form id="Form1" 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 id="Button1" type=button value="Enter" OnServerClick="SubmitBtn_Click" runat=server>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0