views:

189

answers:

2

How do I reset an ASP.NET dropdown, on the click of a link, using Javascript? No JS Frameworks.

Edit: reset, as in set the selected value to the first one in the list, as it would be when the page first loads.

+2  A: 

You would probably want to get the control by ID then set the selectedIndex to 0.
for example:

var q = document.getElementById('dropdownId');
q.selectedIndex = 0;

Hope this helps

TheOne
+2  A: 

Try this link

Do you want to remove all items of the dropdown or Select the first option(Default selected option)?

Try this :

document.getElementById("<%#mydropdownlist.ClientID%>").value = 0;

or

document.getElementById("<%#mydropdownlist.ClientID%>").selectedIndex = 0;
Himadri