Neeraj Verma
Neeraj Verma

Reputation: 263

javascript pop up message not coming on Delete

I am learning MVC Delete Opearation from

https://www.youtube.com/watch?v=ItSA19x4RU0&list=PL6n9fhu94yhVm6S8I2xd6nYz2ZORd7X2v

The View :

@model IEnumerable<BusinessLayer.Employee>
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Emp_id)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Emp_name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Emp_Sal)
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        using (Html.BeginForm("Delete", "Employee", new { id = item.Emp_id }))
        {
            <tr> <td>
            @Html.DisplayFor(modelItem => item.Emp_id)
            </td> <td>
            @Html.DisplayFor(modelItem => item.Emp_name)
            </td> <td>
            @Html.DisplayFor(modelItem => item.Emp_Sal)
            </td> <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.Emp_id }) | <input type="submit"
        value="Delete" onclick="return Confirm("Are you Sure wanna Delete with ID [email protected]_id");"/> </td> </tr>
        }
    }
</table>

What is missing in JavaScript Code ?

Please Suggest ..

Upvotes: 0

Views: 117

Answers (1)

Tom
Tom

Reputation: 7740

You are doing return Confirm(), but the window.confirm method should use a lowercase "c"

Although there are a number of better ways to do what you're trying to do, the answer to the question is to change that line to return confirm(...

@Html.ActionLink("Edit", "Edit", new { id = item.Emp_id }) | <input type="submit"
    value="Delete" onclick="return confirm("Are you Sure wanna Delete with [email protected]_id");"/>

Upvotes: 1

Related Questions