I have code below:
<select id="testSelect">     <option value="1">One</option>     <option value="2">Two</option> </select> <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?
var getValue = document. getElementById('ddlViewBy'). selectedOptions[0]. value; alert (getValue); // This will output the value selected.
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:
Request.Form["testSelect"] 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With