Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use selectedIndexChanged dropdownlist in clientSide and ServerSide

Tags:

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!

like image 210
user1671697 Avatar asked Sep 20 '12 16:09

user1671697


People also ask

How to Call DropDownList SelectedIndexChanged event in ASP net?

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.


2 Answers

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> 
like image 102
Kundan Singh Chouhan Avatar answered Oct 19 '22 07:10

Kundan Singh Chouhan


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> 
like image 21
Adil Avatar answered Oct 19 '22 07:10

Adil