Monday, July 21, 2014

Check Uncheck all items in ASP.Net CheckBoxList using jQuery

<asp:CheckBox ID="chkAll" Text="Select All" runat="server" />
<asp:CheckBoxList ID="chkFruits" runat="server">
    <asp:ListItem Text="Mango" />
    <asp:ListItem Text="Apple" />
    <asp:ListItem Text="Banana" />
    <asp:ListItem Text="Pineapple" />
    <asp:ListItem Text="Guava" />
    <asp:ListItem Text="Grapes" />
    <asp:ListItem Text="Papaya" />
</asp:CheckBoxList>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("[id*=chkAll]").bind("click"function () {
            if ($(this).is(":checked")) {
                $("[id*=chkFruits] input").attr("checked""checked");
            } else {
                $("[id*=chkFruits] input").removeAttr("checked");
            }
        });
        $("[id*=chkFruits] input").bind("click"function () {
            if ($("[id*=chkFruits] input:checked").length == $("[id*=chkFruits] input").length) {
                $("[id*=chkAll]").attr("checked""checked");
            } else {
                $("[id*=chkAll]").removeAttr("checked");
            }
        });
    });
</script>

Reference:

No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...