2017-09-07 1 views
0

Ich habe Probleme mit meinem Popup-Bestätigungsfenster in meinem MVC-Projekt.Bestätigung MessageBox funktioniert nicht in MVC

Grundsätzlich habe ich folgendes:

@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"}) 

} 

Wie Sie oben sehen, wenn ich die „+ document.FileName +“ in der Onclick-Funktion das Popup-Bestätigungsfeld ausgelöst wird, nicht ich bin nicht passieren sicher, warum es nicht funktioniert, aber wenn ich nicht die "+ document.FileName +" wie im Kontext unter der PopUp-Nachricht Box erscheint.

@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"}) 

Was mache ich falsch? oder könnte es etwas geben, dass ich vermisse?

Antwort

0

ich es herausgefunden mich Ich hatte das falsche Format ist folgendes:

@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" }) 

Statt dessen:

@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"}) 
0

Verwendung dieses

@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"}) 

}