我有一个带有多个标记的选择控件的表单。但是当我收到值时,它只是第一个选定的值,而不是我期望的多个值。我预计前“1,4,2”
HTML:
<form>
<select id="responsible" name="responsible" multiple="multiple">
<option value="1">Bare hyggelig</option>
<option value="3">BUA Østensjø</option>
<option value="2">Et Levende Bogerud Beboerforening</option>
<option value="4">Vennegruppe VÅR</option>
</select>
</form>
行动:
public async Task<IActionResult> CreateActivity([FromForm] string responsible)
{
return RedirectToAction("Calendar");
}
将操作变量设置为字符串数组,该值将包含所有选定的选项。
public async Task<IActionResult> CreateActivity([FromForm] string[] responsible)
{
return RedirectToAction("Calendar");
}