我想创建一个两个按钮,点击它时会调用两个不同的动作。我使用Html.BeginForm
创建了一个按钮。
@using (Html.BeginForm("someAction", "someController"))
{
<button type="submit">OK</button>
}
如何在不实际嵌套两个表单的情况下添加第二个按钮?还有其他方法吗?请帮助!
这是我的代码:
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.ContactNumber)
</td>
<td>
@Html.ActionLink("Edit", "EditEmployee", new { id = item.EmployeeID }) |
@Html.ActionLink("Delete", "DeleteEmployee", new { id = item.EmployeeID })
</td>
</tr>
}
答案 0 :(得分:0)
我在使用两个表单一个在另一个之下时,按钮会出现缩进问题。我没有使用任何表格标签就修好了。这是我的答案:
<td>
<a href="@Url.Action("EditEmployee", "Employee", new {id = item.EmployeeID})" class="btn btn-warning btn-sm">
Edit
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
</a>
<a href="@Url.Action("DeleteEmployee", "Employee", new { id = item.EmployeeID })" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete the record with employee name @item.UserName')">
Delete
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</a>
</td>