我想获得下拉列表的选定值,我无法控制runat =“server”
<form id="form" action="Default.aspx" method="post">
<table>
<tbody>
<tr>
<td align="left" >
<select id="formsSelect" style="font-family: arial,sans-serif;font-size:10px;>
<%
for (int x = 0; x < forms.Count; x++)
{
%>
<option><%= forms[x].ToString() %></option>
<%
}
%>
</select>
<input type="submit" name="formType" value="Search" style="color: #000000;"/>
</td>
</tr>
</tbody>
</table>
</form>
任何帮助
答案 0 :(得分:0)
使用JavaScript,您可以将其作为
<script type="text/javascript">
var ddl = document.getElementByID('formsSelect');
// The value is persent in ddl, you can use it as
var selectedvalue= ddl.options[ddl.selectedIndex].value;
</script>
答案 1 :(得分:0)
你不能在代码背后获得html控件值,你应该使用asp:DropDownList控件,然后你就会得到
protected void Dropdown_SelectedIndexChanged(object sender, EventArgs e)
{
string val= Dropdown.SelectedValue.tostring();
}