Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi ,

Here i have checkboxlist item .it loaded dynamically from database.if i select all it not firepage load but if i select any item it will fire pageload. but what i want means if i select all or single i dont want to go page load. below is my code.

design:-
XML
<div runat="server" id="single" style="font-weight:bold;  width: 500px">
                                     
                                               <asp:CheckBoxList ID="CheckBoxList2" Enabled="false"  RepeatColumns="5" RepeatLayout="Table" runat="server" AutoPostBack="false" SelectionMode="Multiple" AppendDataBoundItems="true" DataTextField="customerName" DataValueField="code">
                                        </asp:CheckBoxList>


script:
JavaScript
<div class="op">function CheckAll() {
  //  alert("checkall");
    var intIndex = 0;
    var rowCount = document.getElementById('lstBranch').getElementsByTagName("input").length;
    for (i = 0; i < rowCount; i++) {
        if (document.getElementById('CheckBoxList1').checked == true) {
            if (document.getElementById("lstBranch" + "_" + i)) {
                if (document.getElementById("lstBranch" + "_" + i).disabled != true)
                    document.getElementById("lstBranch" + "_" + i).checked = true;
            }
        }
        else {
            if (document.getElementById("lstBranch" + "_" + i)) {
                if (document.getElementById("lstBranch" + "_" + i).disabled != true)
                    document.getElementById("lstBranch" + "_" + i).checked = false;
            }
        }
    }
}

function UnCheckAll() {
 //   alert("uncheck");
    var intIndex = 0;
    var flag = 0;
    var rowCount = document.getElementById('lstBranch').getElementsByTagName("input").length;
    for (i = 0; i < rowCount; i++) {
        if (document.getElementById("lstBranch" + "_" + i)) {
            if (document.getElementById("lstBranch" + "_" + i).checked == true) {
                flag = 1;
            }
            else {
                flag = 0;
                break;
            }
        }
    }
    if (flag == 0)
        document.getElementById('CheckBoxList1').checked = false;
    else
        document.getElementById('CheckBoxList1').checked = true;

}

if i select all customer or single customer i dont want to fire pageload event.
Posted
v2
Comments
Your CheckBoxList is Enabled="false". How it is working?
JOTHI KUMAR Member 10918227 3-Jul-15 6:08am    
i have two checkboxlist so only i put enable =false thanks to all i got answer thanks thanks
manognya kota 3-Jul-15 6:43am    
can you post your solution and mark the question as solved? the solution might help others.
cheers!

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