Radio Button
Source
<asp:RadioButton ID="rdA" runat="server" Text="A" />
<asp:RadioButton ID="rdB" runat="server" Text="B" />
<asp:Button ID="btnRdBtn" runat="server" OnClick="Button2_Click" Text="Test"/><asp:TextBox ID="txtRdCheck" runat="server"></asp:TextBox>
C#
protected void btnRdBtn_Click(object sender, EventArgs e)
{
if (rdA.Checked && rdB.Checked)
{
txtRdCheck.Text = "AB";
}
else
{
if (rdA.Checked)
{
txtRdCheck.Text = "A";
}
if (rdB.Checked)
{
txtRdCheck.Text = "B";
}
}
}
RadioButton List
Source
asp:RadioButtonList ID="rdBtn" runat="server" Style="font-weight: 700" Width="69px">
<asp:ListItem Value="1">A</asp:ListItem>
<asp:ListItem Value="2">B</asp:ListItem>
<asp:ListItem Value="3">C</asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="btnTst" runat="server" OnClick="btnTst_Click" Text="Test" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
protected void btnTst_Click(object sender, EventArgs e)
{
TextBox1.Text =
rdBtn.SelectedItem.Text;
}
No comments:
Post a Comment