gpt4 book ai didi

asp.net-mvc - 通过确认对话框删除 ActionLink

转载 作者:行者123 更新时间:2023-12-03 04:52:40 26 4
gpt4 key购买 nike

我正在尝试实现一个简单的 ActionLink,它将使用 ASP.NET MVC 删除记录。这是我到目前为止所拥有的:

<%= Html.ActionLink("Delete", 
"Delete",
new { id = item.storyId,
onclick = "return confirm('Are you sure?');"
})%>

但是,它不显示确认框。显然我遗漏了一些东西或者我错误地构建了链接。有人可以帮忙吗?

最佳答案

不要将 routeValueshtmlAttributes 混淆。您可能想要this overload :

<%= Html.ActionLink(
"Delete",
"Delete",
new { id = item.storyId },
new { onclick = "return confirm('Are you sure you wish to delete this article?');" })
%>

关于asp.net-mvc - 通过确认对话框删除 ActionLink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4682107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com