MrM MrM - 3 months ago 10
ASP.NET (C#) Question

How do I trigger a Jquery function with a Drop down list?

I have 2 asp:DropdownLists with an OnSelectedIndexChanged attribute. When that is triggered I would like to run a jquery function that would let the user know the data is being processed. How do I jump to my jQuery function and is there a way I don't have to use the unique id?

<asp:DropDownList ID="ddlFirst" runat="server" OnSelectedIndexChanged="ddlChange">
<asp:ListItem>All</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddlSecond" runat="server" OnSelectedIndexChanged="ddlChange">
<asp:ListItem>All</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
</asp:DropDownList>

$(document).ready(function () {
$("???").change(function () {
//code
});
});

Answer

Give them a class and use $('.yourClass')