gpt4 book ai didi

javascript - 在 razor 中确认 Url.Action

转载 作者:数据小太阳 更新时间:2023-10-29 04:03:08 24 4
gpt4 key购买 nike

您好,我在 gridview 中使用编辑按钮。在调用操作之前我想要一个确认按钮?

grid.Column("","",format:@<text>@if(!item.IsBookPublished)
{
<text> <a href='@Url.Action("EditBookByID","Books", new {BookID = @item.BookDetailsID, CreatedBy = @item.UserID , onclick = "return confirm('Are you sure you want to Edit?')" })'>Edit</a></text>
}
</text>

然而,onclick 属性并未计算,而是作为参数传递。如何获得确认?

最佳答案

你放错地方了。现在您已将它作为参数传递给 Url.Action 帮助程序,而它应该是一个单独的属性,与您定义 href 属性的方式相同:

<a href="@Url.Action("EditBookByID", "Books", new { bookID = item.BookDetailsID, CreatedBy = item.UserID })" onclick="return confirm('Are you sure you want to Edit?')">Edit</a>

顺便说一句,您应该考虑为此使用助手:

grid.Column("", "", format:
@<text>
@if(!item.IsBookPublished)
{
Html.ActionLink(
"Edit",
"EditBookByID",
"Books",
new { bookID = @item.BookDetailsID },
new { onclick = "return confirm('Are you sure you want to Edit?')" }
)
}
</text>
)

关于javascript - 在 razor 中确认 Url.Action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17549550/

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