$(function ()
{
$("#dialog-confirm").dialog(
{
autoOpen: false,
resizable: false,
height: 240,
modal: true,
buttons: {
"Delete": function ()
{
$(this).dialog("close");
return true;
},
Cancel: function ()
{
$(this).dialog("close");
return false;
}
},
close: function() {
;
}
});
});
function ShowDeleteConfirmation()
{
var activeEmelent = document.activeElement;
if (activeEmelent.innerHTML == 'Delete')
{
$('#dialog-confirm').dialog('open');
return false;
}
}
//aspx代码
<asp:LinkButton ID="lbDelete" runat="server" Text="Delete" CssClass="wecc-grid-link" data-cmd="delete" OnClick="Delete_Click" OnClientClick=" return ShowDeleteConfirmation();" ></asp:LinkButton>
//服务器端事件
protected void Delete_Click(object sender, EventArgs e)
{
_deleteClicked = true;
LinkButton lb = sender as LinkButton;
GridViewRow row = lb.Parent.NamingContainer as GridViewRow;
if (row.RowState != (DataControlRowState.Selected | DataControlRowState.Edit) &&
row.RowState != (DataControlRowState.Alternate | DataControlRowState.Selected | DataControlRowState.Edit))
{
Delete(row);
}
else
{
SetRowState(row.RowIndex, DataControlRowState.Normal);
}
gvSaveState.DataSource = this.Data;
gvSaveState.AllowSorting = true;
gvSaveState.DataBind();
lbAddItem.Visible = true;
lbRefreshData.Visible = true;
}
当我单击网格视图中的删除链接按钮时,会弹出对话框。但是,单击对话框中的删除按钮后,它不会触发我的服务器端单击事件。单击删除时,我确实返回了一个值“true”。
在这里感谢您的帮助。