I have an ASP.NET website which uses the jQuery dialog to present the user with a downloads terms dialog. Once the user has agreed to the terms in the dialog, the I perform a server-side postback which issues a Response.Redirect call to a page on another website which is responsible for serving the download to the browser. The problem is that once the Response.Redirect call has been made, the dialog can no longer be shown.
I initialize the dialog in the document.ready event using the following code :-
$('#terms-dialog').dialog({ modal: true, autoOpen: false, autoResize: false, height: 420, width: 500, overlay: { opacity: 0.5, background: 'black' } });
The code to show the dialog is as follows :-
function showTermsDialog(snippetid, title, agreement, url) { $('#terms-dialog-text').html(agreement); $('#terms-dialog-controls').attr('style', 'display: block;'); $('#<%= this.SnippetID.ClientID %>').attr('value', snippetid); $('#<%= this.DownloadUrl.ClientID %>').attr('value', url); $('#terms-dialog').data('title.dialog', title); $('#terms-dialog').dialog('open'); }
This code allows me to successfully show the dialog multiple times, but the call to dialog(‘open’) no longer works after the Response.Redirect call has been made.
Has anyone done anything similar to what I am attempting to do here? Alternatively, if anyone can offer any jQuery dialog debugging tips, these would also be appreciated.
The problem seemed to be caused by an extension function my dialog was using which was positioning the jQuery dialog into the form section of the page, to ensure server-side postbacks would work correctly. I changed the behaviour of this code to instead simply close the dialog and then invoke the serverside callback manually using the following