Thursday, July 1, 2010

How to get Drop Down List 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>

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card