如何解决如何获取有关Url.Action的确认消息?
在这里,我想在单击删除按钮时不使用任何我曾经在 SELECT * FROM `Users`
where
Meta_value like "%blonde%"
and not exists (
SELECT 1 from `Banned_hair_colors`
where `Users`.Meta_value like concat('%',`Banned_hair_colors`.color,'%')
)
上单击过的jquery时获得确认消息,如下所示
Html.Action
但显示<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("Delete","StudentDetails",new { id=item.StudentId},new { onclick = "return confirm('Are sure wants to delete?');" } )'"><i class="fa fa-trash" aria-hidden="true"></i></button><br>
和"cannot convert from '<anonymous type: int id>'to 'System.Web.Routing.RouteValueDictionary'>"
上的new { id=item.StudentId}
错误
任何帮助都会很棒
解决方法
将其拆分可能更容易。
将URL添加到数据属性中,例如
<button data-url="@Url.Action("Delete","StudentDetails",new { id=item.StudentId})" onclick="ConfirmDeletion()"></button>
然后onclick可以调用javascript函数
function ConfirmDeletion()
{
var x = confirm("Are you sure you want to delete?");
if (x) {
var url = this.getAttribute('data-url')
location.href= = url;
}
}
我还没有测试过,但是我认为它更简单明了
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。