96
ASP.NET Web Forms CheckBox
It is used to get multiple inputs from the user. It allows user to select choices from the set of choices.
It takes user input in yes or no format. It is useful when we want multiple choices from the user.
To create CheckBox we can drag it from the toolbox in visual studio.
This is a server side control and ASP.NET provides own tag to create it. The example is given below.
Server renders it as the HTML control and produces the following code to the browser.
This control has its own properties that are tabled below.
Property | Description |
---|---|
AccessKey | It is used to set keyboard shortcut for the control. |
TabIndex | The tab order of the control. |
BackColor | It is used to set background color of the control. |
BorderColor | It is used to set border color of the control. |
BorderWidth | It is used to set width of border of the control. |
Font | It is used to set font for the control text. |
ForeColor | It is used to set color of the control text. |
Text | It is used to set text to be shown for the control. |
ToolTip | It displays the text when mouse is over the control. |
Visible | To set visibility of control on the form. |
Height | It is used to set height of the control. |
Width | It is used to set width of the control. |
Checked | It is used to set check state of the control either true or false. |
Example
// WebControls.aspx
Code Behind
// WebControls.aspx.cs
Initially, there is no course selected then it shows none. It displays user selection as shown in the following screenshot.
Next TopicASP.NET LinkButton