ASP.NET HtmlInputCheckBoxControl
HTML Server Controls
Definition and Usage
The HtmlInputCheckBox control is used to control the <input type="checkbox"> element. In HTML, this element is used to create checkboxes.
Properties and Events
| Property | Description |
|---|---|
| Attributes | Returns a collection of all attribute name and value pairs for the element. |
| Checked | A Boolean value that specifies whether the element is checked. |
| Disabled | A Boolean value that indicates whether the control is disabled. Default is false. |
| id | The unique id of the control. |
| Name | The name of the element. |
| runat | Specifies that the 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 state of the control 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 in the HtmlForm control). When the submit button is triggered, the submit subroutine is executed. This submit subroutine has two types of responses: if the "red" checkbox is checked, the server sends the message "You prefer red!" to the p element. If the "blue" checkbox is checked, the server sends the message "You prefer blue!" to the p element.
HTML Server Controls Other Extensions