これは私の見解です:
@foreach(var action in Model.Category.Actions) {
<div class="action" style="margin-right: 30px;">
<input type="checkbox" class="chk-act" id="@action.Id" name="actionChk" />
<text>@action.Text</text>
</div>
}
そしてhtml Domは次のようなものです:
<input type="checkbox" class="chk-act" id="17" name="actionChk">
<input type="checkbox" class="chk-act" id="18" name="actionChk">
<input type="checkbox" class="chk-act" id="19" name="actionChk">
したがって、チェック済みの ID を取得する必要があります。on
フォームコレクションで値を取得しようとすると、チェックされたチェックボックスの長さの文字列配列が返されました:
[HttpPost]
public ActionResult Index(FormCollection collection) {
var actions = collection.GetValues("actionChk");
return View();
}
あなたの提案は何ですか?