我想从HTML select选项中获取我的所选值/文本,但无法获取!我已经尝试了这个网站上发布的答案,但都不起作用。
这是我的代码:
<select id="Select" name="Select" runat="server">
<option value="1">Option 1</option>
</select>
我尝试了这些C#代码:
//With this I get Index out of range error message:
string name = nombre.Items[nombre.SelectedIndex].Text;
//With this I get nothing:
string name = this.nombre.Value.ToString();
//Nothing here:
string name = this.nombre.Value;
我能帮你做什么?需要使用HTML选择控件。