我有一个基本的 ASP.NET MVC3 视图,如下所示:
@Html.Label("Administrative Options");
<br />
@Html.ListBoxFor(m => m.SelectedUsers, Model.Users)
<br />
using (Html.BeginForm("AssignAdmins", "Account"))
{
<div id="MakeAdminsbtn">
<input id="MakeAdmins" type="submit" value="Assign Administrators" onclick="return confirm('Are you sure you want to Admin?');" />
</div>
}
<br />
using (Html.BeginForm("RevokeAdmins", "Account"))
{
<div id="RemAdminsbtn">
<input id="RemAdmins" type="submit" value="Revoke Administrators" onclick="return confirm('Are you sure you want to De-Admin?');" />
</div>
}
<br />
using (Html.BeginForm("DeleteAccounts", "Account"))
{
<div id="DelAcctbtn">
<input id="DelAcct" type="submit" value="Delete Accounts" onclick="return confirm('Are you sure you want to Delete?');" />
</div>
}
每个按钮都有自己的形式,因为我认为这是我必须做的才能提交不同的操作?
我遇到的问题是返回的模型不包含SelectedUsers
from ,ListBoxFor
除非该语句位于提交按钮使用的表单内。
如何在仅显示单个 ListBox 的同时,为每个给定的提交选项正确填充所选用户的模型?