Monday, January 28, 2013

Asp.net radio buttons

if you have a page thus


      <p>
          <asp:RadioButton GroupName ="tt" ID="RadioButton1" runat="server"  Checked="true" />
            <asp:RadioButton  GroupName ="tt" ID="RadioButton2" runat="server" />
              <asp:RadioButton  GroupName ="tt" ID="RadioButton3" runat="server" />
      </p>
      <asp:Button ID="Button7" runat="server" Text="radio"
          onclick="Button7_Click" />

and code thus:
   protected void Button7_Click(object sender, EventArgs e)
        {
           // this.RadioButton2.Checked = false;
            this.RadioButton1.Checked = true;
        }

and you you select the 2nd radio button and click button7 - what will happen?


since the values are set on load - the button code will do nothing because you can't have to radio buttons selected.



No comments:

Post a Comment