Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a problem with to get delete alert when i click on delete button,actually delete operation done but need popup alert,i used onclick event.

What I have tried:

<table class="table table-bordered table-hover table-responsive table-condensed">
        <tr>
            <th>
                Name
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Password)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Gender)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Designation)
            </th>
            <th>
                Joining Date
            </th>
            <th>
                Working Hours
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Address)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.EmailId)
            </th>
            <th>
                Mobile Number
            </th>
            <th>
                Created by
            </th>
            <th>Actions</th>
        </tr>

        @foreach (var item in Model)
        {
            @Html.HiddenFor(model => item.EmpId)
            <tr>
                <td>
                    @Html.DisplayFor(model => item.Name)
                </td>

                <td>
                    @Html.DisplayFor(model => item.Password)
                </td>

                <td>
                    @Html.DisplayFor(model => item.Gender)
                </td>

                <td>
                    @Html.DisplayFor(model => item.Designation)
                </td>

                <td>
                    @Html.DisplayFor(model => item.JoiningDate)
                </td>

                <td>
                    @Html.DisplayFor(model => item.WorkingHours)
                </td>

                <td>
                    @Html.DisplayFor(model => item.Address)
                </td>

                <td>
                    @Html.DisplayFor(model => item.EmailId)
                </td>

                <td>
                    @Html.DisplayFor(model => item.MobileNumber)
                </td>

                <td>
                    @Html.DisplayFor(model => item.Createdby)
                </td>
                <td>
                    <button type="button" title="Edit" class="btn btn-success glyphicon glyphicon-edit" value="Edit" onclick="location.href='@Url.Action("EditEmpDetails", "Employee", new { id = item.EmpId })'"> Edit</button>
                    <button type="button" title="Delete" class="btn btn-md btn-danger glyphicon glyphicon-trash" value="Delete" onclick="location.href='@Url.Action("DeleteEmp", "Employee", new { id = item.EmpId })' "> Delete</button>                
                       
                                Create New
                            </a>
                        </span>*@
                </td>
            </tr>
        }
    </table>
Posted
Updated 16-Nov-17 3:40am
v3

1 solution

Quote:
get delete alert when i click on delete button,actually delete operation done but need popup alert

try

<script>
    function funDeleteConfirm(url) {
        var canProceed = confirm('Do you want to Delete ?');
        if(canProceed)
            location.href = url;
        return canProceed;
    }
</script>

<button type="button" title="Delete" class="btn btn-md btn-danger glyphicon glyphicon-trash" value="Delete" onclick="return funDeleteConfirm('@Url.Action("DeleteEmp", "Employee", new { id = item.EmpId })') "> Delete</button> 
 
Share this answer
 
Comments
suresh92 16-Nov-17 23:56pm    
Thanks for your support karthik
Karthik_Mahalingam 17-Nov-17 0:08am    
welcome suresh

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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