i'm tryi开发者_开发百科ng to replace the standard javascript confirm function with a JQueryUI dialog. I've searched for solutions, but nothing seems to work for me. What i want is simple: click an ASP.Net button, display the dialog, continue if "Yes" is pressed. Current javascript code:
$(document).ready(function () {
$("#confirmDialog").dialog({
autoOpen: false,
modal: true,
closeOnEscape: false,
bgiframe: true,
open: function (event, ui) { $(".ui-dialog-titlebar-close", ui.dialog).hide() },
buttons: {
"Yes": function () {
$(this).dialog('close');
return true;
},
"No": function () {
$(this).dialog('close');
return false;
}
}
});
});
function showDialog() {
$("#confirmDialog").dialog('open');
return false;
}
ASP.NET code:
<asp:Button ID="DeleteButton" CssClass='button' onmouseout="this.className='button'"
onmouseover="this.className='button:hover'" runat='server' Text='Delete' Width='1in'
Height="30px" OnClientClick="javascript:showDialog();" OnClick="DeleteSetup"/>
What's happening is that the dialog is displayed, but DeleteSetup vb.net sub is called before anything is selected in the dialog.
Thanks in advance for any help or advice.
Try changing your OnClientClick
declaration to this
OnClientClick="return showDialog();"
精彩评论