我在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"));
}
我被卡住了。请帮帮忙。谢谢。
发布于 2012-01-25 17:19:33
我通过下面这篇文章实现了这个解决方案: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()));
}
就这样。希望这能有所帮助!
https://stackoverflow.com/questions/8998787
复制相似问题