RadioButton Problem

Last post 02-09-2009 2:13 AM by Forward Sun - MSFT. 7 replies.

Sort Posts:

  • RadioButton Problem

    01-30-2009, 9:04 AM
    • Participant
      1,657 point Participant
    • paaresh
    • Member since 05-22-2007, 9:21 AM
    • Ahmedabad
    • Posts 255

    Hi...

    try this..... take some radiobuttons

    1    <asp:RadioButton runat="server" ID="rdb1" GroupName="rg1" />
    2    <asp:RadioButton runat="server" ID="rdb2" GroupName="rg1" />
    3    <asp:RadioButton runat="server" ID="rdb3" GroupName="rg1" />
    and write in codebehind :
     
    1    rdb1.Checked = true;
    2    rdb3.Checked = true;
    3    rdb2.Checked = true; 
    
     guess what should be the output ?
     i am getting rdb3 selected. 
    in fact you see generated HTML code, you will find that all the radio button will have "checked = true". 
    and so the last control in generated HTML code is displayed as selected.
    are you all getting same out put..?
    if yes... is it Asp.net bug..?
     
    Paresh

    [GTL-Ahmedabad]
    || Blog ||
  • Re: RadioButton Problem

    01-30-2009, 10:15 AM
    Answer

    This is not an asp.net bug, if you set checked to true on 3 different radio buttons, even though they are in the same group, from a server-side perspective they dont know about each other, so when you set one of the buttons it wouldnt know where to go to try and uncheck the rest of them. Its just rendering therefore what you tell it to, and the browser is then deciding to display the last one.

    I would just suggest amending your code to ensure that you only check one of the boxes, or uncheck the others beforehand. Alternativley try a radiobuttonlist instead, as this control would probably act as a wrapper around the controls and perform the logic for ensuring that only one is checked for you... Worth giving it a try.

  • Re: RadioButton Problem

    01-30-2009, 11:33 PM
    • Participant
      1,657 point Participant
    • paaresh
    • Member since 05-22-2007, 9:21 AM
    • Ahmedabad
    • Posts 255

    yes...

    i know that but if anybody is using RadioButton server control. what he expects is if he is setting one as true other should automatically set to false.

    even you try in RadioButtonList the behaviour is same. in RadioButtonList all controls are in same collection so it should work properly in RadioButtonList. or there should be method like in DropDownList SelectedValue for RadioButtonList.

    i think this is basic need. because if a developer is developing page in which code behind is more that 2000 line. he will think that thare is some problem in his code. but actually it is problem of control.

    and this happened to my friend. he was wondering that problem is in his logic.

    anyway .. Asp.Net team should provide such functionality for RadioButtonList and it is possible. may be not for only RadioButton.

    Thanks,

    Paresh

    [GTL-Ahmedabad]
    || Blog ||
  • Re: RadioButton Problem

    02-04-2009, 3:13 AM
    Answer

    Hi,

    Based on your description, the issue is the the last RadioButton is always checked when we select all of them when they have the same GroupName property.

     As Simon explains, this is caused by .NET design and the browser behaviour.

    We much appreciate your valuabe feedback "I know that but if anybody is using RadioButton server control. what he expects is if he is setting one as true other should automatically set to false." I can reproduce the issue with your steps and I have to admit that the bahaviour is indeed less desirable.

    You can also post the suggestions to our Connect feedback portal. Our developer will evaluate them seriously and take them into consideration.

    http://connect.microsoft.com/VisualStudio/

    Improving the quality of our products and services is a never ending process for Microsoft. Thanks for choosing us.

     

     

    Forward Sun
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: RadioButton Problem

    02-05-2009, 11:07 PM
    • Participant
      1,657 point Participant
    • paaresh
    • Member since 05-22-2007, 9:21 AM
    • Ahmedabad
    • Posts 255

     Hi,

    I have already tried to post the problem i found when faced this issue on Microsoft Connect. but, it is not clearly menstioned anywhere where to post this issue. so i posted here on forums.asp.net.

    can any body please provide information about how to post this type of issue. so it will be helpful to improve quality of the product.

    Thanks,

    Paresh

    [GTL-Ahmedabad]
    || Blog ||
  • Re: RadioButton Problem

    02-06-2009, 12:32 AM

    paaresh:
    can any body please provide information about how to post this type of issue. so it will be helpful to improve quality of the product.

    Hi,

    Thanks for your further information.

    If we never submitted an issue before, we can be navigated to Microsoft feedback connect portal by clicking the “Report a Bug” submenu under “Help” menu of Visual Studio as follow:

    Thanks again for your valuable suggestions and for choosing Microsoft.

     

    Forward Sun
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: RadioButton Problem

    02-07-2009, 1:36 AM
    • Participant
      1,657 point Participant
    • paaresh
    • Member since 05-22-2007, 9:21 AM
    • Ahmedabad
    • Posts 255

     Hi...

    Thanks for providing information.

    but i did not find 'Report a Bug' option in visual studio 2005.

     

    Paresh

    [GTL-Ahmedabad]
    || Blog ||
  • Re: RadioButton Problem

    02-09-2009, 2:13 AM

    Hi,

    In visual studio 2008, please report a bug as described previously. I didn't install visual studio 2005. In this case, we can directly do this throught our feedback connect portal.

     

    Forward Sun
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (8 items)