Dialog + buttons + modal + postback

Dialog + buttons + modal + postback

Hi all,

I'm trying to put JQuery Dialog into my ASP.Net application. The problem I'm getting is that when the user clicks on the "I Agree" button I want to do some server side work and then go back to the same page with a confirmation. So the way I thought about doing it was creating a asp.net button, set to display:none and I would call this from the dialog buttons. Unfortunately I can't call ASP.Net controls from the dialog until I assign the dialog to the form: 
  1.       $dialog.parent().appendTo(jQuery("form:first");
But if I do that, and I'm using modal=true, then the dialog buttons become "hidden" behind the dialog overlay. :( Here's the latest javascript (with previous attempts commented out).

  1.         $(function () {

  2.         //var dlg = 
  3.             $("#declaration-confirmation").dialog({
  4.                 autoOpen: false,
  5.                 height: 400,
  6.                 width: 450,
  7.                 buttons: {
  8.                     "I agree": function () {
  9.                         $('#<%=btnAgreeTerms.ClientID%>').click();
  10.                         $(this).dialog("close");
  11.                     },
  12.                     Cancel: function () {
  13.                         $(this).dialog("close");
  14.                     }
  15.                 }
  16.             });
  17.             //dlg.parent().appendTo(jQuery("form:first"));
  18.         });

  19.         function SubmitForm() {
  20.             Page_ClientValidate();
  21.             if (Page_IsValid) {
  22.                 //$('#declaration-confirmation').dialog({ modal: true });
  23.                 $("#declaration-confirmation").dialog("open");
  24.                 //$('#declaration-confirmation').dialog({ modal: true });
  25.                 //$("#declaration-confirmation").parent().appendTo(jQuery("form:first"));
  26.                 return false;
  27.             }
  28.             else {
  29.                 return false;
  30.             }
  31.         }
Any suggestions on how to get past this problem?
    Kind regards
    Sidharth