我的MVC项目中的弹出确认消息框出现问题。
基本上我有以下内容:
@foreach(document in Model.Documents)
{
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id =
document.Id}, new { onclick = "return confirm('Are you sure you want to delete
this document"+ document.FileName +"?');", @class = "button small button
alert"})
}
如上所示,当我在onclick函数中传递" + document.FileName +" 时,弹出确认框未被触发我不确定为什么它不起作用,但当我不包括" + document.FileName +" 时,就像弹出popUp消息框下面的上下文一样。
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id = document.Id},new { onclick = "return confirm('Are you sure you want to delete this document'?');", @class = "button small button alert"})
我做错了什么?或者可能有任何我失踪的东西?
答案 0 :(得分:0)
我自己弄清楚我的格式不正确:
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id =
document.Id}, new { onclick = "return confirm('Are you sure you want to delete this document" + document.FileName + "?')", @class = "button small button alert" })
而不是:
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id =
document.Id}, new { onclick = "return confirm('Are you sure you want to delete
this document"+ document.FileName +"?');", @class = "button small button
alert"})
答案 1 :(得分:0)
使用此
@foreach(var document in Model.Documents)
{
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { @id =
document.Id, @onclick = "return confirm('Are you sure you want to delete
this document"+ document.FileName +"?');", @class = "button small button
alert"})
}