for radiobutton:
void SubmitBtn_Click(Object Sender, EventArgs e)
{
if (Radio1.Checked)
{
Label1.Text = "You selected " + Radio1.Text;
}
else if (Radio2.Checked)
{
Label1.Text = "You selected " + Radio2.Text;
}
else if (Radio3.Checked)
{
Label1.Text = "You selected " + Radio3.Text;
}
}
</script>
for radiobuttonlist:
script runat="server">
void Button1_Click(object Source, EventArgs e)
{
if (RadioButtonList1.SelectedIndex > -1)
{
Label1.Text = "You selected: " +
RadioButtonList1.SelectedItem.Text;
}
}
void chkLayout_CheckedChanged(Object sender, EventArgs e)
{
if (chkLayout.Checked == true)
{
RadioButtonList1.RepeatLayout = RepeatLayout.Table;
}
else
{
RadioButtonList1.RepeatLayout = RepeatLayout.Flow;
}
}
void chkDirection_CheckedChanged(Object sender, EventArgs e)
{
if (chkDirection.Checked == true)
{
RadioButtonList1.RepeatDirection = RepeatDirection.Horizontal;
}
else
{
RadioButtonList1.RepeatDirection = RepeatDirection.Vertical;
}
}
</script>
radiobutton 可以复选。radiobuttonlist里的radio不可复选