Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I have radiobuttonlist with 3 listitems,from client side in need to get which item is selected,event need trigger from radiobuttonlist,not from any button click event or some other things

ASP.NET
<asp:RadioButtonList ID="radListType"   runat="server">
                    <asp:ListItem Selected="True" Value="User" >User</asp:ListItem>
                    <asp:ListItem Value="Public" >Public</asp:ListItem>
                    <asp:ListItem Value="Private" >Private</asp:ListItem>
                </asp:RadioButtonList>


in this if check "Public",i need to get "Public" value,any event from radiobuttonlist


Regards
Aravind
Posted

Below are the code to get selected radio button value :
JavaScript
var checked_radio = $("[id*=radListType] input:checked");
var value = checked_radio.val();

Hopefully, It will work ...!
 
Share this answer
 
v2
Comments
Aravindba 14-Jan-16 4:31am    
Pls read my question clearly and reply,i am asking radiobuttonlist and not for radio button
If you want to handle click event from client side you can achieve as below.

    <asp:RadioButtonList ID="radListType" AutoPostBack="False"  runat="server">
        <asp:ListItem class="radio-type" Selected="True" Value="User" >User</asp:ListItem>
        <asp:ListItem class="radio-type" Value="Public" >Public</asp:ListItem>
        <asp:ListItem class="radio-type" Value="Private" >Private</asp:ListItem>
    </asp:RadioButtonList>
    
<script>
    $(document).ready(
        function () {
            // If you want to handle selected event. 
            $(".radio-type input[type=radio]").click(
                function() {
                    alert($(this).val());
                }
            );
        }
    );
</script>



if you want to get the selected check box value you can use below

$(".radio-type input[type=radio]:checked").val()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900