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, specifying whether to immediately post back the form after the Checked property is changed. The default is false. |
Checked | Boolean value, specifying 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 | Text should appear on which side of the radio button (left or right)? |
Web 控件标准属性
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled SkinID, Style, TabIndex, ToolTip, Width
如需完整描述,请访问 Web 控件标准属性。
控件标准属性
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site TemplateControl, TemplateSourceDirectory, UniqueID, Visible
如需完整描述,请访问控件标准属性。
实例
- Radiobutton
- 在此例中,我们在 .aspx 文件中声明了三个 RadioButton 控件,一个 Button 控件,以及一个 Label 控件。当提交按钮被触发时,会执行 submit 子例程。submit 子例程会以三种方式响应:如果带有 id="red" 属性的 radiobutton 被选中,服务器向 Label 控件发送消息 "You selected Red";如果带有 id="green" 属性的 radiobutton 被选中,服务器向 Label 控件发送消息 "You selected Green";如果带有 id="blue" 属性的 radiobutton 被选中,服务器向 Label 控件发送消息 "You selected Blue"。