我尝试使用“提交”按钮提交标签选择并且它工作正常但是没有提交按钮怎么样?我想每次在没有 JavaScript 的情况下更改标签选择的值时直接将其发送到控制器。那可能吗 ?@model MyViewModel<form asp-controller="Home" asp-action="Create"> <select asp-for="EmployeeId" asp-items="@(new SelectList(Model.EmployeesList,"Id","FullName"))"> <option>Please select one</option> </select></form>[HttpPost]public IActionResult Create(MyViewModel model){ //check model.EmployeeId //to do : Save and redirect}
1 回答
浮云间
TA贡献1829条经验 获得超4个赞
尝试这个:
<select asp-for="EmployeeId" asp-items="@(new SelectList(Model.EmployeesList,"Id","FullName"))" onchange="this.form.submit()"> ...</select>
- 1 回答
- 0 关注
- 113 浏览
添加回答
举报
0/150
提交
取消
