我使用asp.net core 1.0,在此我想在删除记录上添加客户端确认
我的代码
@model IEnumerable<Login.Model.UserAccount>
@{
ViewData["Title"] = "Home Page";
}
<div class="row">
<div class="col-md-12">
<h2>Registered user</h2>
@if (Model.Any())
{
<table class="table">
<tr>
<th>First name</th>
<th>Last Name</th>
<th>EmaiID</th>
<th>Use Name</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.FirstName</td>
<td>@item.LastName</td>
<td>@item.Email</td>
<td>@item.UserName</td>
<td>
<a asp-action="Edit" asp-route-id="@item.UserID">Edit</a> |
<a asp-action="Delete" asp-route-id="@item.UserID">Delete</a>
</td>
</tr>
}
</table>
}
else
{
<p> There is no registered users.</p>
}
</div>
</div>
在上面的代码删除操作执行成功,但我想在删除前添加添加客户端确认,如果操作正常比删除,如果操作cancle而不是删除。
答案 0 :(得分:0)
function ConfirmDelete()
{
var x = confirm("Are you sure you want to delete?");
return X;
}
<input type="button" Onclick="ConfirmDelete()">