RadioButton control
ASP.NET RadioButton Control
Web server control
Definition and usage
RadioButton control to display radio buttons.
Tip: To create a series of radio buttons using data binding, please use the RadioButtonList control!
Properties
Properties | Description |
---|---|
AutoPostBack | Boolean value, specifies whether to return the form immediately after the Checked attribute is changed. The default is false. |
Checked | Boolean value, 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 that is 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 | On which side of the radio button should the text appear (left or right). |
Example
Radiobutton
In this example, we declared three RadioButton controls in the .aspx file, A Button control, and a Label control. When the submit button is triggered, the submit subroutine is executed. The submit subroutine will respond in three ways: if the radiobutton with the id="red" attribute is selected, the server sends the message "You selected Red" to the Label control; if the radiobutton with the id="green" attribute is selected If selected, the server sends the message "You selected Green" to the Label control; if the radiobutton with the id="blue" attribute is selected, the server sends the message "You selected Blue" to the Label control.
Web Server Control