Getting SelectedIndexChanged event of checkboxlist using javascript

MithunRaj picture MithunRaj · Mar 20, 2012 · Viewed 8.2k times · Source

I have a checkboxlist control in one of the web application. I want to use javascript to handle the SelectedIndexChanged event.

The checkbox list is like

<asp:CheckBoxList ID="CheckBoxList1" runat="server">
    <asp:ListItem>One</asp:ListItem>
    <asp:ListItem>Two</asp:ListItem>
    <asp:ListItem>Three</asp:ListItem>
    <asp:ListItem>Four</asp:ListItem>
    <asp:ListItem>Five</asp:ListItem>
</asp:CheckBoxList> 

How can I get the SelectedIndexChanged event using javascript?

Answer

Thit Lwin Oo picture Thit Lwin Oo · Mar 20, 2012

On server side.. put the follwoing..

CheckBoxList1.Attributes.Add("onclick", "ChangeCheckBox();");

In client side JavaScript section, implement the following function

function ChangeCheckBox() {}