Latest web development tutorials

ASP.NET RadioButton control

Web Server Controls Web server control

Definition and Usage

RadioButton control to display radio button.

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


Attributes

属性 描述
AutoPostBack 布尔值,规定在 Checked 属性被改变后,是否立即回传表单。默认是 false。
Checked 布尔值,规定是否选定单选按钮。
id 控件的唯一 id。
GroupName 该单选按钮所属控件组的名称。
OnCheckedChanged 当 Checked 属性被改变时,被执行的函数的名称。
runat 规定该控件是服务器控件。必须设置为 "server"。
Text 单选按钮旁边的文本。
TextAlign 文本应出现在单选按钮的哪一侧(左侧还是右侧)。


Examples

Radiobutton
In this case, we have declared three RadioButton control in an .aspx file, a Button control, and one Label control. When the submit button is triggered, the submit subroutine. submit subroutine will respond in three ways: if with id = "red" radiobutton property is selected, the server sends a message "You selected Red" to the Label control; if with id = "green" radiobutton property is selected, the server sends a message "You selected Green" to the Label control; if with id = "blue" radiobutton property is selected, the server sends a message to the Label controls "You selected Blue".


Web Server Controls Web server control