Asp.net mvc ASP.net及;MVC:AJAX&;更新PartialView&;确认信息

Asp.net mvc ASP.net及;MVC:AJAX&;更新PartialView&;确认信息,asp.net-mvc,jquery,confirmation,asp.net-mvc-partialview,Asp.net Mvc,Jquery,Confirmation,Asp.net Mvc Partialview,我正在使用ASP.NETMVC制作我的应用程序 实际上,我正在尝试从数据库中删除一个条目,首先我必须有一条确认消息,当操作完成时,我想刷新我的PartialView 这是我的密码 <%= Ajax.ActionLink( "Supprimer", "Delete", "Users", new { item.ID }, new AjaxOptions

我正在使用ASP.NETMVC制作我的应用程序

实际上,我正在尝试从数据库中删除一个条目,首先我必须有一条确认消息,当操作完成时,我想刷新我的PartialView

这是我的密码

          <%= Ajax.ActionLink(
            "Supprimer", 
            "Delete", 
            "Users",
            new { item.ID },
            new AjaxOptions {
              Confirm= "confirmMethod",
              UpdateTargetId = "usersListeID",
              OnSuccess = "success"
           }
              )%>

您可以使用标准的
Html.ActionLink

<%= Ajax.ActionLink(
    "Supprimer", 
    "Delete", 
    "Users",
    new { item.ID },
    new { @class = "delete" }
) %>

什么是“简单ajax消息?”@Andrey您可以使用jQuery对话框。请尝试此链接以获取答案,但此解决方案会更新整个页面,我只想更新我的部分视图(ID为#userslisteind),这就是我显示的代码所做的。如果AJAX调用成功,它将使用
Delete
操作返回的内容更新
#usersListeID
元素。因此,请确保此操作只返回要更新的部分HTML,而不是整个视图。
<%= Ajax.ActionLink(
    "Supprimer", 
    "Delete", 
    "Users",
    new { item.ID },
    new { @class = "delete" }
) %>
$(function() {
    $('.delete').click(function() {
        var anchor = this;
        // Show the confirmation dialog
        $.msgBox({
            title: "Demande de confirmation",
            content: "Voulez-vous effectuer cette action?",
            type: "confirm",
            buttons: [{ value: "Oui" }, { value: "Non"}],
            success: function (result) {
                if (result == "Oui") {
                    // send the AJAX request if the user selected "Oui":
                    $.ajax({
                        url: anchor.href,
                        type: 'POST',
                        success: function(data) {
                            // When the AJAX request succeeds update the 
                            // corresponding element in your DOM
                            $('#usersListeID').html(data);
                        }
                    });
                }
            }
        });

        // Always cancel the default action of the link
        return false;
    });
});