Asp.net mvc 使用beginform传递值
我的观点是:Asp.net mvc 使用beginform传递值,asp.net-mvc,Asp.net Mvc,我的观点是: @using (Html.BeginForm()) { @Html.HiddenFor(o=>o.NoteId) for (int i = 0; i < Model.Friends.Count; i++) { <table> <tr> <td> <p style="font-size: 1.3
@using (Html.BeginForm())
{
@Html.HiddenFor(o=>o.NoteId)
for (int i = 0; i < Model.Friends.Count; i++)
{
<table>
<tr>
<td>
<p style="font-size: 1.3em; color: black">@Model.Friends[i].Name</p>
</td>
<td>
@Html.CheckBoxFor(x => @Model.Friends[i].Checked)
</td>
</tr>
</table>
}
但它只在我的复选框前面显示属性(名称)。
关于如何实现这一点的任何提示?为了恢复名称,您需要使用能够生成
输入
元素的工具,以便它成为表单集合的一部分
使用@Html.HiddenFor()
for (int i = 0; i < Model.Friends.Count; i++)
{
<table>
<tr>
<td>
<p style="font-size: 1.3em; color: black">@Model.Friends[i].Name</p>
</td>
<td>
@Html.CheckBoxFor(x => @Model.Friends[i].Checked)
@Html.HiddenFor(x => @Model.Friends[i].Name
</td>
</tr>
</table>
}
for(int i=0;i@Model.Friends[i].姓名
@Html.CheckBoxFor(x=>@Model.Friends[i].选中)
@Html.HiddenFor(x=>@Model.Friends[i].Name
}
设置一个隐藏字段。我不熟悉razor视图引擎,但谷歌快速推荐@Html.HiddenFor
for (int i = 0; i < Model.Friends.Count; i++)
{
<table>
<tr>
<td>
<p style="font-size: 1.3em; color: black">@Model.Friends[i].Name</p>
</td>
<td>
@Html.CheckBoxFor(x => @Model.Friends[i].Checked)
@Html.HiddenFor(x => @Model.Friends[i].Name
</td>
</tr>
</table>
}