单击删除按钮而不是使用MVC的actionlink时删除弹出警报 [英] Delete popup alert when I click on delete button not actionlink using MVC

查看:80
本文介绍了单击删除按钮而不是使用MVC的actionlink时删除弹出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击删除按钮时,我有一个问题是获取删除警报,实际删除操作已完成但需要弹出警报,我使用onclick事件。



< b>我尝试了什么:



< table class =table table-bordered table-hover table-responsive table -condensed> 
< tr>
< th>
姓名
< / th>
< th>
@ Html.DisplayNameFor(model => model.Password)
< / th>
< th>
@ Html.DisplayNameFor(model => model.Gender)
< / th>
< th>
@ Html.DisplayNameFor(model => model.Designation)
< / th>
< th>
加入日期
< / th>
< th>
工作时间
< / th>
< th>
@ Html.DisplayNameFor(model => model.Address)
< / th>
< th>
@ Html.DisplayNameFor(model => model.EmailId)
< / th>
< th>
手机号码
< / th>
< th>

< / th>创建
< th>动作< / th>
< / tr>

@foreach(模型中的var项)
{
@ 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 =buttontitle =编辑class =btn btn-success glyphicon glyphicon-editvalue =编辑onclick =location.href ='@ Url.Action(EditEmpDetails ,员工,新{id = item.EmpId})'>编辑< /按钮>
< button type =buttontitle =删除class =btn btn-md btn-danger glyphicon glyphicon-trashvalue =删除onclick =location.href ='@ Url.Action( DeleteEmp,Employee,new {id = item.EmpId})'>删除< /按钮>

新建
< / a>
< / span> * @
< / td>
< / tr>
}
< / table>

解决方案

引用:

当我点击删除按钮时获取删除警告,实际删除操作已完成但需要弹出警报



尝试



< script> 
function funDeleteConfirm(url){
var canProceed = confirm('你想删除吗?');
if(canProceed)
location.href = url;
return canProceed;
}
< / script>



< button type =buttontitle =Deleteclass = btn btn-md btn-danger glyphicon glyphicon-trashvalue =Deleteonclick =return funDeleteConfirm('@ Url.Action(DeleteEmp,Employee,new {id = item.EmpId})') >删除< /按钮> 


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>

解决方案

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> 


这篇关于单击删除按钮而不是使用MVC的actionlink时删除弹出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆