ポスト コントローラー アクションへの RadioButtonFor のバインドに問題があります。下記参照。
メイン ビュー- アクションを呼び出して部分ビューを読み込み、それをフォームで囲む
@using (Html.BeginForm("FilterPlaceInPriorPosition", "Placements", FormMethod.Post))
{
@Html.Action("AdvancedSearch", "Home", new { Area = "Common", advancedSearchModel = Model.AdvancedSearch })
}
AdvancedSearch 部分コントローラ アクション
public ActionResult AdvancedSearch(AdvancedSearch advancedSearchModel)
{
return PartialView("_AdvancedSearch", advancedSearchModel);
}
部分ビュー- _AdvancedSearch.cshtml
@model AdvancedSearch
<div class="row">
<div class="col-sm-4">
@Html.TextBoxFor(model => model.Search, new { @class = "form-control no-max-width" })
</div>
<div class="col-sm-8">
@Html.RadioButtonFor(model => model.MyActiveStudents, true, new {Name = "studentTypeRadio"}) <label for="MyActiveStudents">My active students</label>
@Html.RadioButtonFor(model => model.AllActiveStudents, true, new {Name = "studentTypeRadio"}) <label for="AllActiveStudents">All active students</label>
</div>
</div>
コントローラー アクションの投稿-FilterPlaceInPriorPosition
[HttpPost]
public ActionResult FilterPlaceInPriorPosition(AdvancedSearch filter)
{
return RedirectToAction("PlaceInPriorPosition", filter);
}
AdvancedSearch.cs クラス
public class AdvancedSearch
{
public bool MyActiveStudents { get; set; }
public bool AllActiveStudents { get; set; }
画像を見ると、テキストボックスのテキストはバインドされていますが、2 つのラジオボタンはバインドされていないことがわかります。 デバッグ結果イメージ