Consider an ASP.NET webforms app where the requirement is to raise a confirm dialog when an asp:LinkButton
is clicked. The results of the confirm dialog should allow or block the postback for the linkButton_click
method.
The plugin/library currently being used is the jquery.alerts.js
(found on ABeautifulSite).
<script src="http://labs.abeautifulsite.net/projects/js/jquery/alerts/demo/jquery.js"
type="text/javascript"></script>
<script src="http://labs.abeautifulsite.net/projects/js/jquery/alerts/demo/jquery.ui.draggable.js"
type="text/javascript"></script>
<!-- Core files -->
<script src="http://labs.abeautifulsite.net/projects/js/jquery/alerts/demo/jquery.alerts.js"
type="text/javascript"></script>
<link href="http://labs.abeautifulsite.net/projects/js/jquery/alerts/demo/jquery.alerts.css"
rel="stylesheet" type="text/css" />
<asp:LinkButton runat="server" ID="lnkDisable"
Text="Disable This Emp" onclick="lnkDisable_Click" />
<script type="text/javascript">
$(document).ready(function() {
$("#ctl00_mainContent_lnkDisable").click(function() {
jConfirm('Please confirm this emp should be disabled?',
'Confirm Disable',
function(r) {
jAlert('Confirmed: ' + r, 'Results');
});
});
});
</script>
The message box fires properly!
Problem The problem is that it shows for about 2 seconds, and then the page is posted-back before the user can make a selection on the popup. I've set a breakpoint on that event handler, and indeed the page is posted back.
Question How can I have the post-back delayed while the user makes up their mind and clicks on the OK or Cancel button on the popup?
Any suggestions on another plugin are welcome!