Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

I want to select all and deselect all checkbox using jquery in asp.net with c#
please, help me out soon
Posted
Updated 17-Oct-11 3:41am
v2
Comments
RaviRanjanKr 17-Oct-11 9:43am    
please avoid text word like plz, always write complete word like Please.
pal5hah 19-Oct-11 0:44am    
why?

Hi,

Here I'm providing some code for your requirement .

check this once

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language="javascript" >
        function f1(tid) {
         
            if ($("#" + tid).val() == 'A') {
                $('#dt1').find("input:checkbox").each(function () {
                    this.checked = true;
                });

            }
            else {
                $('#dt1').find("input:checkbox").each(function () {
                    this.checked = false;
                });
            }
        }
       
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <br />
        <asp:radiobuttonlist id="RadioButtonList1" runat="server" repeatdirection="Horizontal" xmlns:asp="#unknown">
        <asp:listitem text="Select All" value="A" onclick="f1(this.id)"></asp:listitem>
        <asp:listitem text="Delect All" value="D" onclick="f1(this.id)"></asp:listitem>
        </asp:radiobuttonlist><br />
        <table width="50%" align="center" id="dt1">
            <tr> <td>   <input type="checkbox" id="ch1" />
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" />
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" />
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" />
                </td>
            </tr>
          </table>
    </div>
    </form>
</body>
</html>


All the Best
 
Share this answer
 
Comments
pal5hah 18-Oct-11 4:48am    
this code is not working..wt should i do?
Muralikrishna8811 18-Oct-11 4:54am    
Hi,

import that jquery files from net
copy to your project and gave reference to them
pal5hah 18-Oct-11 4:51am    
Scripts/jquery-1.4.1-vsdoc.js
Scripts/jquery-1.4.1.js

give me this two folders
Muralikrishna8811 18-Oct-11 4:55am    
you can download them from here
http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
pal5hah 18-Oct-11 5:06am    
there is no "onclick" event in <asp:listitem>
 
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