开发者

Radio Buttons in ASP.NET

开发者 https://www.devze.com 2023-02-03 18:54 出处:网络
I\'m bit new to .NET. I am using Radio buttons inside a panel in a web page. (Since group boxes are not there).

I'm bit new to .NET. I am using Radio buttons inside a panel in a web page. (Since group boxes are not there). But when I click on each radio button they all are checked. They are not acting as a group but sing开发者_StackOverflow中文版le units.

Do I need to remove the panel here? Please help me.


You're probably missing GroupName

<asp:RadioButton id="button1" runat="server" GroupName="MyGroup" Text="Button 1" />
<asp:RadioButton id="button2" runat="server" GroupName="MyGroup" Text="Button 2" />
<asp:RadioButton id="button3" runat="server" GroupName="MyGroup" Text="Button 3" />


You can use the Radiobuttonlist in ASP.NET toolbar.

And in the SelectedIndexChanged event of the radiobuttonlist you can do what ever you want as you wish. (rblist is the radiobuttonlist)

protected void rbList_SelectedIndexChanged(object sender, EventArgs e)
{
    if (rbList.Items[0].Selected)
    {
        lblHeader.Text = "You selected first option";
    }
}


What you want is <asp:RadioButtonList>.

0

精彩评论

暂无评论...
验证码 换一张
取 消