title: Click ASP.NET button from jQuery dialog button event
body: <p>I have the following ASP.NET markup:</p>
  
  <pre><code>&lt;div id="myForm" title="My Form" style="display: none"&gt;
      &lt;span&gt;You can see me!&lt;/span&gt;
      &lt;div style="display: none"&gt;
          &lt;asp:Button ID="btnSave" runat="server" Text="Button"
              OnClick="btnSave_Click" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- called by an element click event elsewhere --&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
      $("#myForm").dialog({
          modal: true,
          width: 500,
          height: 200,
          resizable: false,
          buttons: {
              "Cancel": function () {
                  $(this).dialog("close");
              },
              "Save": function () {
                  $(this).dialog("close");
                  // I want to call btnSave_Click (by DOM-clicking the button?)
              }
          }
      });
      $("#myForm").parent().appendTo("form:first");
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm trying to get the jQuery.dialog generated buttons to perform the postback in place of the ASP.NET button. What should I do to make the button do a submit and call the <code>btnSave_Click</code> method?</p>
  
  <hr />
  
  <h3>EDIT</h3>
  
  <pre><code>"Save": function () {
      $(this).dialog("close");
      document.getElementById("&lt;%=btnSave.ClientID %&gt;").click();
  }
  </code></pre>
  
  <p>... works but is this the best solution?</p>