我想在删除之前提示确认对话框。我在这里找到this的答案,效果很好
@Html.ActionLink(
"Delete",
"Delete",
new { id = post.OriginalPost.ID },
new { onclick = "return confirm('Are you sure you wish to delete this post?');" });
但是据我在Core中了解,应该避免使用ActionLinks。那么,有没有标签助手或其他方式来做到这一点?
答案 0 :(得分:2)
您通常会使用AnchorTagHelper
:
<a asp-action="Delete" asp-route-id="@post.OriginalPost.ID"
onclick="return confirm('Are you sure you wish to delete this post?');">Delete</a>