Set RadioButtons checked/unchecked with JavaScript

2 posts, 0 answers
  1. Lindsay
    Lindsay avatar
    5 posts
    Member since:
    Nov 2008

    Posted 23 Jan 2009 Link to this post

    I read a previous post here to just change the CssClass of the label next to the radio button with JavaScript.  This works visually, but it does not set the checked state of the radio button itself.  So on postback, my radio button does not read as checked.

    I saw in the changelog for Q3 2008 that this was changed.  But i do not see any information in the documentation as to how I can now "easily" set these values with JavaScript.  Little help here please?  =)

    Also, I have another problem I'm not sure anyone can help me with... My subscription ran out and the last version I was able to download of the Telerik Asp.Net controls was Q1 2008.1.619.  The "free" RadFormDecorator installation told me it was installing ALL controls - so now that DLL contains "trial" versions for ALL the other controls.  Is it possible to have my valid 2008.1.619 AND the new RadFormDecorator Q3 2008?  I would hope so, since the RadFormDecorator Q3 2008 is being advertised as free...
  2. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 26 Jan 2009 Link to this post

    Hi Lindsay,

    Here is how you can check a button in a decorated radiobutton list - in addition to the actual radiobutton's check you will need to change the classes for the skinned elements as well:

    <script type="text/javascript"
    function checkRadioButton() 
        //get the checked button 
        var realRadio = $get("RadioButtonlist1_1"); 
        //get the decorated checked button 
        var skinnedRadio = $get("_radfd_Skinned"+; 
        var radios = $get("RadioButtonlist1").getElementsByTagName("label"); 
        var i = 0
        for (i<0; i<radios.length; i++) 
            radios[i].className = "Default radfdRadioUnchecked"
        //change the class so the decorated button will look checked 
        skinnedRadio.className = "Default radfdRadioChecked"
        //check the real button 
        realRadio.checked = true
            <telerik:RadFormDecorator ID="RadFormDecorator1" Visible="true" DecoratedControls="all" 
                runat="server" /> 
            <asp:RadioButtonList ID="RadioButtonlist1" runat="server"
                <asp:ListItem Text="item1" Selected="true"></asp:ListItem> 
                <asp:ListItem Text="item2"></asp:ListItem> 
            <button onclick="checkRadioButton(); return false;"
                check RadioButton 2</button> 

    As for your second question, I see that Paul has already answered your support ticket on the same subject. In short, the free version of RadFormDecorator is provided with trial versions of the other RadControls for ASP.NET AJAX since they are sharing a common assembly.

    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top