从jquery对话框按钮调用asp.net方法

时间:2013-05-08 15:30:36

标签: jquery

我想要创建删除确认对话框。 这是我的jquery对话框

$(function () {
    $("#del-dialog").dialog({
        autoOpen: false,
        width: 300,
        height: 100,
        modal: true,
        close: function (event, ui) {
            location.reload(false);
        },
        buttons: {
            'Delete': function () {
                $(this).dialog('close');
                // delete function goes here

             },
             'Cancel': function () {
                  $(this).dialog('close');
              }
        },
   });

   $(".icon-del").click(function (event) {
        event.preventDefault();
        $("#del-dialog").dialog("open");
    });
});

我的asp代码:

    l += "<a onclick='hello(";
                l += dr["cID"].ToString();
                l += ");'>";
                l += "</a>";

如何从对话框按钮处理删除功能?

1 个答案:

答案 0 :(得分:0)

$(function () {
    $("#del-dialog").dialog({
        autoOpen: false,
        width: 300,
        height: 100,
        modal: true,
        close: function (event, ui) {
            location.reload(false);
        },
        buttons: {
            'Delete': function () {
                $(this).dialog('close');
                var target=$("#del-dialog").data("event").currentTarget
                $(target).data('isConfirming', true); 
                target.click();
                $(target).data('isConfirming', null);

             },
             'Cancel': function () {
                  $(this).dialog('close');
              }
        },
   });

   $(".icon-del").click(function (event) {
       if($(event.currentTarget).data('isConfirming')) return;
        event.preventDefault();
        $("#del-dialog").data("event",event);
        $("#del-dialog").dialog("open");
    });
});