如题!

解决方案 »

  1.   

    使用groupname属性,看例子:<%@ Page Language="C#" AutoEventWireup="True" %>
    <html>
     <head>
        <script language="C#" runat="server">
     
           void Button1_Click(Object sender, EventArgs e) {
              if (Radio3.GroupName == "RegularMenu") {
                 Radio3.GroupName = "VegitarianMenu";
                 Radio3.BackColor = System.Drawing.Color.LightGreen;
              } 
              else {
                Radio3.GroupName = "RegularMenu";
                Radio3.BackColor = System.Drawing.Color.Pink;
              }
           }    
     
        </script>
     </head>
     <body>
     
         <h3>Panel Example</h3>
     
         <form runat=server>
     
            <asp:Label id="Label1" BackColor="Pink" Text="RegularMenu" runat="server"/>
            &nbsp;
     
            <asp:Label id="Label2" BackColor="LightGreen" Text="VegitarianMenu" runat="server"/>
            <p>
     
            <asp:RadioButton id="Radio1" GroupName="RegularMenu"
                 Text="Beef" BackColor="Pink" runat="server"/>
     
            <p>
            <asp:RadioButton id="Radio2" GroupName="RegularMenu"
                 Text="Pork" BackColor="Pink" runat="server"/>
     
            <p>
            <asp:RadioButton id="Radio3" GroupName="RegularMenu"
                 Text="Fish" BackColor="Pink" runat="server"/>
     
            <p>
            <asp:RadioButton id="Radio4" GroupName="VegitarianMenu"
                 Text="Mushroom" BackColor="LightGreen" runat="server"/>
     
            <p>
            <asp:RadioButton id="Radio5" GroupName="VegitarianMenu"
                 Text="Tofu" BackColor="LightGreen" runat="server"/>
     
            <p>
            <asp:Button id="Button1" OnClick="Button1_Click"
                 Text="Regroup the radio buttons" runat="server"/>
     
        </form>
     
     </body>
     </html>
      

  2.   

    C#中,System.Windows.Forms.RadioButton只能通过GroupBox进行分组。
    RadioButton没有那个属性控制自己与哪些其他的RadioButton进行分组。所以还是用GroupBox吧!