title: Run javascript after form submission in update panel?
body: <p>This is driving me crazy! I have read at least 5 questions on here closely related to my problem, and probably 5 or so more pages just from googling. I just don't get it.</p>
  
  <p>I am trying to have a jqueryui dialog come up after a user fills out a form saying 'registration submitted' and then redirecting to another page, but I cannot for the life of me get any javascript to work, not even a single alert.</p>
  
  <p>Here is my update panel:</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
  &lt;/asp:ScriptManager&gt;
  &lt;asp:UpdatePanel ID="upForm" runat="server" 
      UpdateMode="Conditional" ChildrenAsTriggers="False"&gt;
      &lt;ContentTemplate&gt;
                 'Rest of form'
           &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" /&gt; 
                &lt;p&gt;Did register Pass? &lt;%= registrationComplete %&gt;&lt;/p&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>The Jquery I want to execute: (Right now this is sitting in the head of the markup, with autoOpen set to false)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  function pageLoad() {
  
      $('#registerComplete').dialog({
          autoOpen: true,
          width: 270,
          resizable: false,
          modal: true,
          draggable: false,
          buttons: {
            "Ok": function() {
            window.location.href = "someUrl";
          }
          }
      });
  
  }
       &lt;/script&gt;
  </code></pre>
  
  <p>Finally my code behind: ( Commented out all the things I've tried)</p>
  
  <pre><code>Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click     
        'Dim sbScript As New StringBuilder()'
             registrationComplete = True
              registrationUpdatePanel.Update()
  
              'sbScript.Append("&lt;script language='JavaScript' type='text/javascript'&gt;" + ControlChars.Lf)'
              'sbScript.Append("&lt;!--" + ControlChars.Lf)'
              'sbScript.Append("window.location.reload()" + ControlChars.Lf)'
              'sbScript.Append("// --&gt;" + ControlChars.Lf)'
              'sbScript.Append("&lt;/")'
              'sbScript.Append("script&gt;" + ControlChars.Lf)'
  
              'ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "AutoPostBack", sbScript.ToString(), False)'
              'ClientScript.RegisterStartupScript("AutoPostBackScript", sbScript.ToString())'
                              'Response.Write("&lt;script type='text/javascript'&gt;alert('Test')&lt;/script&gt;")'
              'Response.Write("&lt;script&gt;windows.location.reload()&lt;/script&gt;")'
  End Sub
  </code></pre>
  
  <p>I've tried: </p>
  
  <ul>
  <li><p>Passing variables from server to
  client via inline &lt;%= %> in the
  javascript block of the head tag.</p></li>
  <li><p>Putting that same code in a script<br>
  tag inside the updatePanel.</p></li>
  <li><p>Tried to use<br>
  RegisterClientScriptBlock and<br>
  RegisterStartUpScript</p></li>
  <li><p>Just doing a Response.Write with the 
  script tag written in it.</p></li>
  <li><p>Tried various combinations of putting
  the entire jquery.dialog code in the 
  registerstartup script, or just<br>
  trying to change the autoOpen<br>
  property, or just calling "open" on<br>
  it.</p></li>
  </ul>
  
  <p>I can't even get a simple alert to work with any of these, so I am doing something wrong but I just don't know what it is.</p>
  
  <p>Here is what I know:</p>
  
  <ul>
  <li><p>The Jquery is binding properly even
  on async postbacks, because the div
  container that is the dialog box is
  always invisible, I saw a similiar
  post on here stating that was causing
  an issue, this isn't the case here.</p></li>
  <li><p>Using page_load instead of<br>
  document.ready since that is supposed
  to run on both async and normal<br>
  postbacks, so that isn't the issue.</p></li>
  <li><p>The update panel is updating
  correctly because <code>&lt;p&gt;Did register
  Pass? &lt;%= registrationComplete
  %&gt;&lt;/p&gt;</code> updates to true after I
  submit the form.</p></li>
  </ul>
  
  <p>So how can I make this work? All I want is -> click submit button inside an update panel -> run server side code to validate form and insert into db -> if everything succeeded, have that jquery (modal) dialog pop up saying hey it worked.</p>