This documentation is archived and is not being maintained.

HtmlInputCheckBox Constructor

Initializes a new instance of the HtmlInputCheckBox class.

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

public HtmlInputCheckBox()

Use this constructor to create and initialize a new instance of the HtmlInputCheckBox class.

The following table shows the initial property value for an instance of HtmlInputCheckBox.


Initial Value


The "checkbox" literal string.

The following code example demonstrates how to create and initialize a new instance of the HtmlInputCheckBox class.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" >
    <title>HtmlInputCheckBox Constructor Sample</title>
<script language="C#" runat="server">

       // Create a new instance of HtmlInputCheckBox.
       HtmlInputCheckBox cb = new HtmlInputCheckBox();

       // Create a new instance of Label.
       Label label = new Label();

       // Create a new instance of Button.
       HtmlButton b = new HtmlButton();

       protected void Page_Load(object sender, EventArgs e)
           // Define attributes of Button and Label.
           b.InnerText = "Click";
           label.Text = "checkbox";

           // Add controls to placeholder
           Container.Controls.Add(new LiteralControl("<br />"));

           // Add EventHandler
           b.ServerClick += new EventHandler(button_ServerClick);


       void button_ServerClick(object sender, EventArgs e)
           switch (cb.Checked)
               case true:
                   Message.InnerHtml = "Checkbox is checked.";

                   Message.InnerHtml = "Checkbox is not checked.";



   <h3>HtmlInputCheckBox Constructor Sample</h3>

   <form id="form1" runat="server">

      <asp:PlaceHolder id="Container" runat="server"></asp:PlaceHolder>    

      <br />
      <span id="Message" 



Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0