ASP.NET HtmlInputCheckBox Control
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
Properties |
Description |
Attributes |
Returns all attribute names and value pairs of the element.
|
Checked
| A boolean value specifying whether the element is selected.
|
Disabled
| A boolean value indicating 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 the control is a server control. It 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 indicating whether the control is visible.
|
Event |
Description |
ServerChange |
This event occurs when the control state changes. |
Example
- HTMLInputCheckBox
- In this example, we declare two HtmlInputCheckBox controls, one HtmlInputButton control, and one HtmlGeneric control in the .aspx file. When the submit button is triggered, the submit subroutine is executed. This submit subroutine has two response modes: if the "red" checkbox is selected, the server will send the message "You prefer red!" to the p element. If the "blue" checkbox is selected, the server will send the message "You prefer blue!" to the p element.