jQuery & JavaScript

Get the selected value or text of an ASP.NET DropDownList with JavaScript or jQuery

jQuery & JavaScript · · Published 2026-09-09

A DropDownList is a <select> in the browser. The selected item has two pieces of information: its value (the value attribute, usually an id) and its text (what the user reads). Both are one property away, in plain JavaScript or in jQuery.

JavaScript and jQuery code reading the selected value and text of a DropDownList
Reading the value and the text of the selected item.

The control

<asp:DropDownList ID="ddlSize" runat="server">
    <asp:ListItem Value="" Text="-- size --" />
    <asp:ListItem Value="S" Text="Small" />
    <asp:ListItem Value="M" Text="Medium" />
    <asp:ListItem Value="L" Text="Large" />
</asp:DropDownList>
<span id="sizeInfo"></span>

Plain JavaScript

var ddl = document.getElementById("<%= ddlSize.ClientID %>");

var value = ddl.value;                                   // "M"
var text = ddl.selectedIndex >= 0
    ? ddl.options[ddl.selectedIndex].text                // "Medium"
    : "";
// In current browsers, also: ddl.selectedOptions[0].text

.text returns the option's text with white space collapsed; .textContent returns it raw. selectedIndex is -1 only when nothing is selected, which cannot happen in a normal single-selection list with at least one option, but the check costs nothing.

jQuery

var $ddl = $("#<%= ddlSize.ClientID %>");

var value = $ddl.val();                         // "M"
var text = $ddl.find("option:selected").text(); // "Medium"

Use $ddl.find("option:selected") rather than a global $("option:selected"), which would collect the selected options of every list on the page.

Reacting to a change

// plain JavaScript
ddl.addEventListener("change", function () {
  var info = document.getElementById("sizeInfo");
  info.textContent = this.value === ""
      ? "Please choose a size."
      : "You chose " + this.options[this.selectedIndex].text + " (" + this.value + ").";
});

// jQuery
$ddl.on("change", function () {
  var $opt = $(this).find("option:selected");
  $("#sizeInfo").text($opt.val() ? "You chose " + $opt.text() : "Please choose a size.");
});

textContent and jQuery's .text() insert the option text as text, never as HTML, which keeps the page safe even if option labels come from user data.

The placeholder item

A first item with an empty value such as "-- size --" is a common way to force a choice. Test the value, not the index or the text, to know whether the user picked something. On the server, a RequiredFieldValidator with InitialValue="" enforces the same rule, as shown in Validate a DropDownList.

Multi-select ListBox

An asp:ListBox with SelectionMode="Multiple" renders <select multiple>. Collect every selected option:

var lb = document.getElementById("<%= lbTags.ClientID %>");
var values = Array.from(lb.selectedOptions, function (o) { return o.value; });

// jQuery: val() returns an array for multiple selects (an empty array when nothing is selected, jQuery 3+)
var values2 = $("#<%= lbTags.ClientID %>").val();

On the server

The same information is available after a postback through ddlSize.SelectedValue and ddlSize.SelectedItem.Text. Do not rely on values read by script and copied into hidden fields: read the control itself and validate the value. Setting the selection from script is the subject of Set a DropDownList's selected value or text.

Official documentation