Hasan Gürsoy Hasan Gürsoy - 1 year ago 89
HTML Question

How to get selected value of a html select with asp.net

I have code below:

<select id="testSelect">
<option value="1">One</option>
<option value="2">Two</option>
<asp:Button ID="btnTest" runat="server" Text="Test it!" onclick="btnTest_Click" />

I need to get selected options' value on postback. How can I do this with asp.net?

Answer Source

You need to add a name to your <select> element:

<select id="testSelect" name="testSelect">

It will be posted to the server, and you can see it using:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download