ASP.NET HtmlInputCheckBox Control
HTML Server Controls
Definition and Usage
The HtmlInputCheckBox control is used to control the element. In HTML, this element is used to create a check box.
Properties and Events
| property | Description |
|---|---|
| Attributes | Returns all attribute name and value pairs of the element. |
| Checked | A Boolean value that specifies whether the element is checked. |
| Disabled | A Boolean value that indicates whether the control is disabled. The default is false. |
| id | The unique id of the control. |
| Name | The name of the element. |
| runat | Specifies that this control is a server control. Must be set to "server". |
| Style | Sets or returns the CSS properties applied to the control. |
| TagName | Returns the tag name of the element. |
| Type | The type of the element. |
| Value | The value of the element. |
| Visible | A Boolean value that indicates whether the control is visible. |
| Events | Description |
|---|---|
| ServerChange | This event occurs when the control's state changes. |
Example
HTMLInputCheckbox
In this example, we declare two HtmlInputCheckBox controls, one HtmlInputButton control, and one HtmlGeneric control in the .aspx file (remember to nest the controls inside the HtmlForm control). When the submit button is triggered, the submit subroutine is executed. This submit subroutine responds in two ways: if the "red" check box is checked, the server sends the message "You prefer red!" to the p element. If the "blue" check box is checked, the server sends the message "You prefer blue!" to the p element.
HTML Server Controls