开发者

using html select tag in Asp.net

开发者 https://www.devze.com 2023-02-20 12:29 出处:网络
When I use following Html Tag in my Asp.net source code I encounter this error message: <select runat=\"server\" onchange=\"showcity();\" class=\"textbox\" id=\"DpCity\" name=\"DpCity\">

When I use following Html Tag in my Asp.net source code I encounter this error message:

 <select runat="server" onchange="showcity();" class="textbox" id="DpCity" name="DpCity">
      <option value="0" selected="selected">unknown</option>
 </select>

Error message in runtime:

DataBinding: 'System.Web.UI.HtmlControls.HtmlSelect' does开发者_如何学Go not contain a property with the name 'SelectedValue'.

what's wrong?


SelectedValue is not a property of a Select control. Select is different than DropDownList. To get the selected value of the Select list, use this code:

var selectedValue = DpCity.Value;
0

精彩评论

暂无评论...
验证码 换一张
取 消