function showConfirmDialog(event) { if (!$(this).data("IsConfirmed")) { $("#dialog-confirm").data("button", this); $("#dialog-confirm").dialog('open'); return false; } else { $(this).data("IsConfirmed", false); return true; } } $(function () { $("#dialog-confirm").dialog({ resizable: false, modal: true, autoOpen: false, buttons: { 'Confirm': function (event) { $(this).dialog('close'); var button = $(this).data("button"); $(button).data("IsConfirmed", true); button.click(); }, Cancel: function () { $(this).dialog('close'); } } }); //Link or Button click $(".lkConfirm").data("IsConfirmed", false).bind("click", {}, showConfirmDialog); });