I am trying to put some jquery UI code into an existing asp.net app, and could use a helping hand...
I have a button, when a user clicks it, I want to popup a jquery UI dialog with two go/nogo confirmation buttons.
This works except, when I click the button, it opens and then immediately closes...as a new jquery user, I am sure I am just missing something simple...
Here is the javascript to open the dialog:
<script type="text/javascript" >
$(function() {
// Cancel Event Dialog Box
$('#CancelDialog').dialog({
autoOpen: false,
width: 500,
buttons: {
"Cancel This Event": function() {$(this).dialog("close");},
"Do Not Cancel": function() {$(this).dialog("close");}
}
});
});
</script>
and here is the code that calls it:
<asp:Button id="btnCancelMeeting" Text="Cancel Event" runat="server" />
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#CancelDialog').dialog();
$('#btnCancelMeeting').click(function() {$('#CancelDialog').dialog('open'); });
});
</script>
<div id="CancelDialog" title="Cancel and Event or Meeting"><p>Cancel this event.</p></div>
To recap: I click the button, I get the dialog with the two buttons and message that I want, but it closes by itself about 1 second later...What am I doing wrong?
EDIT: OK, now I think I see what is going on...when I click the button, the dialog pops as desired, but then the page is reloading again from the server...which resets the entire page, including clearing the dialog.
So what I really want to happen, is mimic this behavior:
<asp:Button id="btnDelete" Text="Delete Event" runat="server" OnClientClick='javascript:return confirm("Are you sure you would like to permanently delete this event/meeting? This action cannot be undone.")' OnClick="btnDelete_Click" />
where the click generates a client-side event, and only if "OK" is chosen, does the page force a reload. Can anyone give the syntax for hanging this queryUI dialog box off of the OnClientClick event?