I have two checkbox lists, i want to get the count of checked elements of these. below is my code:
<div id="divAreaListingByLocation">
<asp:CheckBoxList ID="chklstArea" CssClass="chkarea" RepeatColumns="6" RepeatDirection="Vertical"
runat="server" OnSelectedIndexChanged="chklstArea_SelectedIndexChanged" AutoPostBack="true">
</asp:CheckBoxList>
</div>
<asp:Repeater ID="repRooms" runat="server" OnItemDataBound="repRooms_ItemDataBound">
<ItemTemplate>
<div style="height: 100%; float: none;">
<asp:Panel ID="pnlRoomheader" runat="server" Style="width: 98%; background-color: #86ADD6;
color: #4A4A4A; height: 20px; margin-top: 10px; text-align: left; padding: 5px;
font-size: 15px; font-weight: bold;">
<asp:Label ID="lblAreaName" runat="server"></asp:Label>
<asp:Label ID="lblAreaId" Style="display: none;" runat="server"></asp:Label>
</asp:Panel>
<div id="divRoomListingByLocation" style="padding-bottom: 10px; padding-top: 10px;">
<asp:CheckBoxList ID="chkRoomList" CssClass="chkRooms" RepeatColumns="6" RepeatDirection="Vertical"
runat="server">
</asp:CheckBoxList>
<asp:Label ID="lblRoomMessage" Text="This Area does not have any room." ForeColor="Red"
runat="server"></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
What i want to do is: if user not checked any of the check box from these two then it will prompt a alert to say check one of the checkbox from both lists on the click of a button.
I have tried to it with class but the class is append to the table render in html of checkboxlist.
Since you are using checkbox list it will apply the specified class to the Table not the checkbox. There you will have to use
This will return the count of all the checkboxes that are checked for a checkboxlist with class “chkarea”