我有需要克隆的输入类型,下面是示例 html。
<input type="text"id="person" name="Person" class="person-list" />
<input type="text"id="person" name="Person" class="person-list" />
我想通过MVC获取两个输入的值。下面的代码是我目前的工作,但它只获取第一个输入的值。
[HttpPost]
public ActionResult ConfirmationPage(string Person){
}
最佳答案
你的方法需要是
public ActionResult ConfirmationPage(string[] Person){ // or IEnumerable<string>
但是,由于重复的 id
属性,您还创建了无效的 html,因此您也应该从输入中删除这些属性。
关于javascript - ASP MVC Controller 发布具有不同值的相同 html 输入名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33071652/