0

I want to delete the record of employee using Post Method. I replaced the html.Actionlink with button. I also want to prompt user for confirmation before deleting the record.
I have written following code:

<input value="Delete" type="submit" onclick="return confirm('Are you sure want to delete ID = @item.EmpId');"/>

This line is showing error "unterminated string constant", what's wrong in this code?

my complete view code

<table border="1">
    <tr>

        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Gender)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.City)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DID)
        </th>
        <th>Action
        </th>

    </tr>

    @foreach (var item in Model)
    {
        using (Html.BeginForm("Delete", "Employee",new{id=item.EmpId}))
        {
        <tr>

            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Gender)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.City)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DID)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.EmpId }) |
                @Html.ActionLink("Details", "Details", new { id = item.EmpId }) |

                <input value="Delete" type="submit" onclick="return confirm('Are you sure want to delete ID = @item.EmpId');"/>
            </td>
        </tr>
        }
    }

</table>
Amit Kumar
  • 5,888
  • 11
  • 47
  • 85

1 Answers1

-1

Just run the application.let the error be there. You wont get any error at complile or run time.It will run as expected.

Avinash
  • 1
  • 2