【发布时间】:2016-03-22 07:15:11
【问题描述】:
为什么在顶部添加 BeginForm 标签会在编辑和详细信息部分旁边显示“删除”按钮?附上代码和图片。
@foreach (var item in Model)
{
using (Html.BeginForm("Delete", "Employee", new { id = item.EmployeeID}))
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Gender)
</td>
<td>
@Html.DisplayFor(modelItem => item.City)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepartmentID)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOfBirth)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.EmployeeID }) |
@Html.ActionLink("Details", "Details", new { id = item.EmployeeID }) |
<input type="submit" value="Delete"
onclick="return confirm('Are you sure you want to delete user @item.Name');" />
</td>
</tr>
}
}
【问题讨论】:
-
因为
input type="submit"是一个按钮,而不是像edit这样的链接。为您的输入添加一个类并创建一个 CSS 样式,让它看起来像您想要的那样。
标签: html asp.net-mvc razor