2012-06-28 97 views
0

我的查询是,我有一个组合框在我的窗体在HTML中,我想将组合框的选定项目的值传递到服务器端一个aspx页面,获取组合框在服务器端的选定值

<form method="POST" action="page.aspx"> 
    <input id="customerName" name="customerName" type="Text" /> 
    <input id="customerPhone" name="customerPhone" type="Text" /> 
    <select id="combobox" > 
     <option>df</option> 
     <option>as</option> 
    </select> 
    <input  
</form> 
value="Save" type="Submit" /> 

在服务器端我用下面的代码集,选择文本框的值

string n = String.Format("{0}", Request.Form['customerName']); 

,但如何获得选择的组合框的值值 请帮帮我 在此先感谢

+0

请检查您会得到了selectedValue的Request.Form [“CUSTOMERNAME”] – Adil

+1

你选择的元素需要名称; Request.Form键入名称属性。添加一个名称,如name =“MyComboBox”,然后Request.Form [“MyComboBox”]应该为您提供值。出于兴趣,为什么不使用 dash

回答

1

您可以尝试修复您的HTML:

<form method="POST" action="page.aspx"> 
    <input id="customerName" name="customerName" type="text"> 
    <input id="customerPhone" name="customerPhone" type="text"> 
    <select id="combobox" name="combobox"> 
     <option value="df">df</option> 
     <option value="as">as</option> 
    </select> 
    <input value="Save" type="submit"> 
</form> 

选择的值将被张贴Request.Form['combobox']

相关问题