如何获得一个HTML的选定值与asp.net选择 [英] How to get selected value of a html select with asp.net
本文介绍了如何获得一个HTML的选定值与asp.net选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面我有code:
<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" />
我需要选择的选项上回发的价值。我怎样才能做到这一点用asp.net?
I need to get selected options' value on postback. How can I do this with asp.net?
推荐答案
您需要一个名字添加到您的&LT;选择&GT;
元素:
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"]
这篇关于如何获得一个HTML的选定值与asp.net选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文