I 클래스 아래에 있습니다체크 박스 목록이
public class ControllerSecurityModel
{
public string ControlleName { get; set; }
public string DisplayName { get; set; }
public List<ActionSecurityModel> actions { get; set; }
}
public class ActionSecurityModel
{
public string ActionName { get; set; }
public string DisplayName { get; set; }
public bool IsChecked { get; set; }
}
및 모델 :
나는 각 "ActionSecurityModel"의 체크 박스를 갖고 싶어public class PageRoleModel
{
public List<ControllerSecurityModel> AllPages { get; set; }
public List<ControllerSecurityModel> SelectedPage { get; set; }
}
, 나는 아래 쓰기 보기 :
<% using (Html.BeginForm())
{%>
<% foreach (var cont in Model.AllPages)
{%>
<fieldset>
<legend>
<%= cont.DisplayName %></legend>
<% foreach (var act in cont.actions)
{%>
<%: Html.CheckBoxFor(x => act.IsChecked) %>
<%: Html.Label(act.DisplayName) %>
<% } %>
</fieldset>
<% } %>
<input type="submit" value="save"/>
<% } %>
이 내 컨트롤러 조치 :
public ActionResult SetRole()
{
PageRoleModel model = new PageRoleModel();
return View(model);
}
[HttpPost]
public ActionResult SetRole(PageRoleModel model)
{
return View(model);
}
하지만 양식을 제출하면 모델이 null입니까? 확인란을 제출하고 저장하려면 어떻게해야합니까? 이처럼
고맙습니다. – Shayan