How to get DropDownList selected text in ASP.NET by using jQuery
The Following code sample shows how to get selected text out from ASP .NET Drop Down List.
<script type="text/javascript"> function GetSelectedText() { var ddlID = '#' + '<%= ddlEmployees.ClientID %>'; var selectedText = $(ddlID + " option:selected").text(); return selectedText; } </script> <asp:DropDownList ID="ddlEmployees" runat="server"> <asp:ListItem Text="Employee Name 1" Value="1"></asp:ListItem> <asp:ListItem Text="Employee Name 2" Value="2"></asp:ListItem> <asp:ListItem Text="Employee Name 2" Value="2"></asp:ListItem> </asp:DropDownList>
Leave a Reply