ASP.NET RadioButtonControl


Web Server ControlsWeb Server Control

Definition and Usage

The RadioButton control is used to display a radio button.

Tip:To create a series of radio buttons using data binding, use the RadioButtonList control!


Properties

Property Description
AutoPostBack Boolean value that specifies whether to post back the form immediately after the Checked property is changed. Default is false.
Checked 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 to be 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, a Button control, and a 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 radiobutton with id="red" is selected, the server sends the message "You selected Red" to the Label control; if the radiobutton with id="green" is selected, the server sends "You selected Green"; if the radiobutton with id="blue" is selected, the server sends "You selected Blue".


Web Server ControlsWeb Server Control Other Extensions