<asp:RadioButton ID="RadioButton1" Text="男" runat="server" GroupName="Sex" />//text属性是Radiobutton显示的值,因为性别只能选一个,所以两个Radiobutton的GroupName是一致的
<asp:RadioButton ID="RadioButton2" Text="女" runat="server" GroupName="Sex"/>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{ if (RadioButton1.Checked)//说明点的是RadioButton1
{ Response.Write(RadioButton1.Text);//输出RadioButton1.Text,即男 }
if (RadioButton2.Checked)//说明点的是RadioButton1 { Response.Write(RadioButton2.Text);//输出RadioButton1.Text,即女 } }