【问题标题】:How can i use Jquery ui dialog confirmation for gridview linkbutton?我如何使用 Jquery ui 对话框确认 gridview 链接按钮?
【发布时间】:2012-01-25 06:37:53
【问题描述】:

我在 Gridview 中有一个用于删除项目的链接按钮。我想用这个按钮使用(jquery ui 对话框确认)。

      <asp:LinkButton ID="lnkDelete" Font-Size="12px" runat="server" CausesValidation="False" CommandName="Delete" Text="Sil"></asp:LinkButton>

我可以像这样使用 jquery ui 对话框确认:(asp.button)

      function onayMesaj(msg) {
                    $("#divMesaj").html(msg);
              $("#divMesaj").dialog({
                  modal: true,
                  bgiframe: true,
                  buttons: {
                      "Yes": function () {
                         <%=this.Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this.btnGuncelleEkle))%>;
                      },
                       "No": function () {
                          $(this).dialog("close");
                      }
                  }
              });
              $("#divMesaj").parent().appendTo($("form:first"));
          }

我被困住了。请帮忙。谢谢。

【问题讨论】:

  • 你坚持什么?你还没有解释什么是有效的,什么是无效的。

标签: jquery gridview dialog linkbutton confirmation


【解决方案1】:

我可以通过以下帖子实现此解决方案:http://www.junnark.com/Blog/Detail/13

基本上,您的删除按钮应该是这样的:

<asp:ImageButton ID="IBtnDelete" runat="server" CommandArgument='<%#Eval("idcustomer")%>' 
    OnClientClick="javascript:return deleteItem(this.name, this.alt);"
    ToolTip="Click to delete" ImageUrl="~/Images/imagesActions/delete_action.png"
    AlternateText='<%#Eval("name")%>' OnCommand="deleteCommand" />

你的 javascript 函数应该是这样的:

function deleteItem(uniqueID, customerID) {
    var dialogTitle = 'Permanently delete ' + customerID + '?';   
    $('#' + '<%=linkDelete.ClientId %>').html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Please click delete to confirm deletion.</p>');
    $('#' + '<%=linkDelete.ClientId %>').dialog({
        title: dialogTitle,
        buttons: {
            "Delete": function () { __doPostBack(uniqueID, ''); $(this).dialog("close"); },
            "Cancel": function () { $(this).dialog("close"); }
        }
    });

    $('#' + '<%=linkDelete.ClientId %>').dialog('open');
    return false;
}

而且,在您的代码隐藏中,您应该有删除所选项目的命令。像这样的:

protected void deleteCommand(object sender, CommandEventArgs e)
    {
        customerDA cus = new customerDA();
        cus.deleteCustomer(Convert.ToInt32(e.CommandArgument.ToString()));
    }

就是这样。希望这会有所帮助!

【讨论】:

  • 伙计,我做了你以前做过的事情,而且效果很好:))我真的很感激。
  • 太棒了。乐意效劳。干杯!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-20
  • 1970-01-01
  • 1970-01-01
  • 2021-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多