简体   繁体   English

列表框发布的表单数据

[英]Listbox posted Form data

im trying to post all the options' value in a select element(listBox) back to server to a MVC project 我试图将选择元素(listBox)中的所有选项值发布回服务器到MVC项目

<select mulitple name="listboxA">
  <option value="one">text one</option>
  <option value="two">text one</option>
  <option value="three">text one</option>
</select>

However, on srever side, the value in Request.Form("listboxA") is "one,two,three," , there is an extra comma at the end, which result in an extra unwanted empty string in the parameter (type of List<string> ). 但是,在更严格的方面, Request.Form("listboxA")值为"one,two,three," ,末尾有一个额外的逗号,这导致参数(类型为List<string> )。

any ideas? 有任何想法吗?

您可以在控制器上使用Request.Form["listboxA"].TrimEnd(',')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM