【发布时间】:2011-05-07 05:56:17
【问题描述】:
我想使用 jQuery UI 的对话框来实现一个确认对话框,当用户单击删除链接时显示该对话框(使用 asp:LinkButton 实现)。
我正在使用如下所示的代码(从 jquery ui 文档中复制):
<!-- the delete link -->
<asp:LinkButton ID="btnDelete" runat="server" Text="Delete"
OnClick="btnDelete_Click" CssClass="btnDelete"></asp:LinkButton>
<!-- the confirm-dialog -->
<div id="dialog-confirm-delete" title="Delete?" style="display:none;">
<p>Are you sure you want to permanently deleted the selected items?</p>
</div>
<script>
$(document).ready(function () {
// setup the dialog
$('#dialog-confirm-delete').dialog({
autoOpen: false,
modal: true,
buttons: {
"Delete all items": function () {
$(this).dialog("close");
// ===>>> how to invoke the default action here
},
Cancel: function () { $(this).dialog("close"); }
}
});
// display the dialog
$('.btnDelete').click(function () {
$('#dialog-confirm-cancel').dialog('open');
// return false to prevent the default action (postback)
return false;
});
});
</script>
所以在click 事件处理程序中,我必须阻止LinkButton(回发)的默认操作,而是显示对话框。
我的问题是:如果用户单击对话框中的“删除所有项目”按钮,我该如何调用删除链接的默认操作(回发)来执行回发?
【问题讨论】:
标签: asp.net jquery-ui jquery-ui-dialog webforms