1
我的問題在於如何發送列表值到控制器上的ajax帖子。用我的實際代碼,這個列表在發佈後是空的。如何使用ajax發佈列表
我的觀點:
@using (Html.BeginForm("UsersList", "Project", FormMethod.Post, new { id = "Users" }))
{
<div id="MyList" >
<table>
<thead>
<tr><th></th><th>User</th><th>End date</th></tr>
</thead>
@Html.EditorFor(x => x.GetUsers)
</table>
</div>
<script type="text/javascript">
$(function() {
$('#MyList).dialog({
autoOpen: false,
width: 820,
buttons: {
"Save": function() {
$("#Users").submit();
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
</script>
型號:
public class ProjectModel
{
public List<ProjectList>GetUsers{get;set;}
}
public class ProjectList
{
public bool Selected { get; set; }
public int UserID { get; set; }
}
我的控制器:
[HttpPost]
public ActionResult UsersList(ProjectModel model)
{
return View(model);
}