How to read the value of selected checkbox inside a checkboxList?

Posted by Starx on Stack Overflow See other posts from Stack Overflow or by Starx
Published on 2010-06-03T08:07:34Z Indexed on 2010/06/03 8:14 UTC
Read the original article Hit count: 247

Filed under:

I want to know the selected value of the markup below. So that I can disabled a textbox, if one of the checkbox is selected.

    <asp:CheckBoxList ID="ChkTest" runat="server" RepeatDirection="Horizontal" CssClass="toggleYesNo">
        <asp:ListItem Value="1">Yes</asp:ListItem>
        <asp:ListItem Value="0">No</asp:ListItem>
    </asp:CheckBoxList>

I tried using this function it doesnot seem to work

$(document).ready(function() {
    $("#<%=ChkTest.ClientID %>").click(function() {
        value = $(this).val();
        if(value=='1') {
            $('#atextbox').attr('disabled','');
         }
         else {
            $('#atextbox').attr('disabled','disabled');
         }           

    });
});

I also track the output HTML but the id the CheckBoxList the assigned to a table instead.

© Stack Overflow or respective owner

Related posts about ASP.NET