Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I'm having an issue with my Popup confirmation message box in my MVC project.
basically i have the following:

C#
//document.FileName is the file name i'm returning from the database
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id = document.Id, caseId = document.CaseId },
                                 new { onclick = "return confirm('Are you sure you want to delete this document'"+ document.FileName +"'?');", @class = "button small button alert"})


When i trigger the ActionLink above the popup confirmation box does not pop up at all.
but when i have the following :

C#
@Html.ActionLink("Delete", "DeleteDocument", "Document", new { id = document.Id, caseId = document.CaseId },
                                 new { onclick = "return confirm('Are you sure you want to delete this document'?');", @class = "button small button alert"})

without the document.FileName as a parameter the pop up box works.

What am i doing wrong?
could someone shed some light on this please.

What I have tried:

I have tried to google and move things around but still no luck and i'm kinda running out patience now
Posted
Updated 6-Sep-17 14:06pm
Comments
j snooze 6-Sep-17 17:19pm    
I don't think you need the single quotes around the double quotes on the file name.

1 solution

Change this:
HTML
@Html.ActionLink("Delete", "DeleteDocument", "Document", 
    new { id = document.Id, caseId = document.CaseId },
    new { onclick = "return confirm('Are you sure you want to delete this document'"+
          document.FileName +"'?');", @class = "button small button alert"})

to this:
HTML
@Html.ActionLink("Delete", "DeleteDocument", "Document", 
    new { id = Model[0].ToString(), caseId = Model[0].ToString() },
    new { onclick = "return confirm('Are you sure you want to delete this document " +
          document.FileName + "?');", @class = "button small button alert" })
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900