Last post Jan 15, 2009 03:44 PM by Visual Web Developer
Jan 15, 2009 03:10 PM|Visual Web Developer|LINK
I use 2 radiobuttons on the webpage where radioButton1 is Checked by defualt and radioButton2 is unchecked by default. Then with the Events below when pressing radioButton2, I want radioButton1 to be unchecked and when pressing radiobutton1 again I want
radioButton2 to be unchecked so simply only one of them can be checked.
But when having radioButton1 checked as default and when clicking radioButton2, radiotButton1 will
Not be unchecked as I want it, so I wonder what I can be doing wrong ?
Jan 15, 2009 03:31 PM|DerickC|LINK
Visual Web Developer
radioButton1 is Checked by defualt
Do not make it checked by default.
In page load event.
if not page.ispostback then
radiobutton1.checked = true
Jan 15, 2009 03:38 PM|Visual Web Developer|LINK
Jan 15, 2009 03:39 PM|budugu|LINK
Do you have same groupname for both buttons?
<asp:RadioButton ID="RadioButton1" runat="server" GroupName ="group1" AutoPostBack="True" OnCheckedChanged="RadioButton1_CheckedChanged" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName ="group1" AutoPostBack="True" OnCheckedChanged="RadioButton2_CheckedChanged" />
Jan 15, 2009 03:44 PM|Visual Web Developer|LINK
You are right, this was the problem. I did manually put this in the properties now and this works. It seems that (software C#) does that automatically.
Thank you for help !!!