<form asp-action="Delete"> @foreach (var item in Model.Items) { <input type="checkbox" name="chk" value="@item.ID" /> } </form>
[HttpPost, ValidateAntiForgeryToken] public async Task<IActionResult> Delete() { return Json(new { success = true }); }
这里如何取得checkbox的值,request吗?
[HttpPost, ValidateAntiForgeryToken] public async Task<IActionResult> Delete(string[] chk) { return Json(new { success = true }); }
谢谢
试试下面的方式
public async Task<IActionResult> Delete([FromBody]bool? chk) {
return Json(new { success = true });
}