Dav*_*eli 6 c# asp.net-core-mvc asp.net-core asp.net-core-tag-helpers
我想在删除之前提示确认对话框。我在这里找到了这个很好用的答案
@Html.ActionLink(
"Delete",
"Delete",
new { id = post.OriginalPost.ID },
new { onclick = "return confirm('Are you sure you wish to delete this post?');" });
Run Code Online (Sandbox Code Playgroud)
但正如我在 Core 中的理解,应该避免使用 ActionLinks。那么是否有任何标签助手或不同的方法来做到这一点?
您通常会使用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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3633 次 |
| 最近记录: |