问题是:我有一个视图,它在用户模型上显示用户的ID和他的特征,使用foreach语句。
这是UserPartial:
@model Project.User
@foreach (User user in Model)
{
<table class="simple-little-table" cellspacing='0'>
<tr>
<td>Id @user.Id </td>
<td>characteristic:@user.Charact</td>
<td><button id="but">User Ban</button></td>
</tr>
</table>
}
<div id="dialog1" title="Dialog Title">@Html.Partial("UserPartial")</div>
$(function () {
$( "#dialog1" ).dialog({
autoOpen: false
});
$("#but").click(function() {
$("#dialog1").dialog('open');
});
});
这是UserPartial:
<div class = "aaa">
@using (Html.BeginForm("BansUsers", "Bans", FormMethod.Post))
{
<div class="editor-label">
@Html.Label("Patronimyc")
@Html.TextBoxFor(model => model.Surname)
</div>
<div class="editor-label">
@Html.Label("Name")
@Html.TextBoxFor(model => model.Name)
@Html.ValidationMessageFor(model=>model.Name)
</div>
<input type="submit" id="submit" value="Ban User" />
}
如何从foreach循环中传递用户ID到弹出窗口?例如,在弹出窗口中向我给出:“您选择了用户编号5”
感谢回答!