ASP.NET RadioButton Control
Definition and Usage
The RadioButton control is used to display radio buttons.
Tip:To create a series of radio buttons using data binding, use the RadioButtonList control!
Property
Property | Description |
---|---|
AutoPostBack | Boolean value, indicating whether to immediately post back the form after the Checked property is changed. The default is false. |
Checked | Boolean value, indicating whether the radio button is selected. |
id | The unique id of the control. |
GroupName | The name of the control group to which the radio button belongs. |
OnCheckedChanged | The name of the function to be executed when Checked is changed. |
runat | Specifies that the control is a server control. Must be set to "server". |
Text | Text next to the radio button. |
TextAlign | The text should appear on which side of the radio button (left or right). |
Web Control Standard Properties
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled SkinID, Style, TabIndex, ToolTip, Width
For a complete description, please visit Web Control Standard Properties.
Control Standard Properties
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible
For a complete description, please visitControl Standard Properties.
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 will be executed. The submit subroutine will respond in three ways: if the radiobutton with the id="red" attribute is selected, the server sends a message "You selected Red" to the Label control; if the radiobutton with the id="green" attribute is selected, the server sends a message "You selected Green" to the Label control; if the radiobutton with the id="blue" attribute is selected, the server sends a message "You selected Blue" to the Label control.