【问题标题】:call asp.net onClick method from jquery dialog button从 jquery 对话框按钮调用 asp.net onClick 方法
【发布时间】:2013-05-12 19:40:07
【问题描述】:

这是我传递 cID 值的 admin.aspx.cs 文件锚标记。

    string l = "";
    while (dr.Read()) //sqldatareader
    {
    l += "<li class='icon-del' >";
                l += "<a id='del' runat='server' onClick='delete' href='?id=";
                l += dr["cID"].ToString();
                l += "'>";
                l += "</a>";
                l += "</li>";
     }
    lit_Category.Text = l;

然后在 admin.aspx 中的 Literal 上显示为

     <asp:Literal runat="server" ID="lit_Category" > </asp:Literal> 

我想使用 jquery 对话框确认删除

    $(function () {
    $("#del-dialog").dialog({
    autoOpen: false,
    width: 300,
    height: 100,
    modal: true,
    close: function (event, ui) {
        location.reload(false);
    },
     buttons: {
         'Delete': function () {
             $("#<%=del.ClientID %>").click(); 
                $(this).dialog('close');  
        },
        'Cancel': function () {
            $(this).dialog('close');
        }
    }
});

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

“删除”按钮应该调用我的 admin.aspx.cs 页面上的 delete() 函数。

【问题讨论】:

    标签: jquery asp.net jquery-ui-dialog


    【解决方案1】:

    在“删除”事件函数中试试这个:

    $.ajax({
        url: "admin.aspx/delete?cid=1",
        success: function(data) {
            alert('deleted');
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-31
      • 1970-01-01
      • 2015-01-20
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      • 2011-02-24
      • 1970-01-01
      相关资源
      最近更新 更多