How use selectedIndexChanged from asp.net dropdownlist in clientSide and ServerSide?
In clientside i want call javascript funcition!
<script type="text/javascript"> function changeCursor() { document.body.style.cursor="progress"; } </script> <asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" AutoPostBack="True" OnSelectedIndexChanged="SelectedChange"> </asp:DropDownList>
SelectedChange is a name of function in clientside!
Thanks for help!
First the ASP.Net DropDownList will be referenced using JavaScript or jQuery on Client Side and then its SelectedIndexChanged event will be called by making use of the __doPostBack JavaScript function. The following HTML Markup consists of an ASP.Net DropDownList, ASP.Net LinkButton and an HTML Button.
Add your client side function name in onchange events of dropdown like below :
<asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" AutoPostBack="True" OnSelectedIndexChanged="SelectedChange" onchange="changeCursor()"> </asp:DropDownList>
In HTML (.aspx)
<asp:DropDownList ID="DropDownSubject" runat="server" DataTextField="Word" AutoPostBack="True" OnSelectedIndexChanged="SelectedChange" onchange="YourChangeFun(this);"> </asp:DropDownList>
In javascript
<script type="text/javascript"> function YourChangeFun(ddl) { alert(ddl.selectedIndex); } </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With