ASP.NET RadioButton Control
Web Server Controls
Definition and Usage
The RadioButton control is used to display a radio button.
**Tip:** To create a series of data-bound radio buttons, use the RadioButtonList control!
property
| property | Description |
|---|---|
| AutoPostBack | A Boolean value that specifies whether the form is immediately posted back after the Checked property is changed. The default is false. |
| Checked | A Boolean value that specifies whether the radio button is selected. |
| id | The unique id of the control. |
| GroupName | The name of the control group to which this radio button belongs. |
| OnCheckedChanged | The name of the function executed when the Checked property is changed. |
| runat | Specifies that the control is a server control. Must be set to "server". |
| Text | The text next to the radio button. |
| TextAlign | Which side of the radio button the text should appear on (left or right). |
Example
Radiobutton
In this example, we declare three RadioButton controls, one Button control, and one Label control in the .aspx file. When the submit button is triggered, the submit subroutine is executed. The submit subroutine responds in three ways: if the radio button with id="red" is selected, the server sends the message "You selected Red" to the Label control; if the radio button with id="green" is selected, the server sends the message "You selected Green" to the Label control; if the radio button with id="blue" is selected, the server sends the message "You selected Blue" to the Label control.
Web Server Controls