为什么html helper beginform格式化显示的方式

时间:2015-04-01 19:06:16

标签: html asp.net-mvc razor

为什么在顶部添加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>
    }
}

enter image description here

1 个答案:

答案 0 :(得分:0)

input type = submit表示按钮..您可以自定义按钮的样式,但是您可以自定义编辑和详细信息,因为它们会将您重定向到另一个页面。