title: How do I combine jQuery and ASP.net to communicate enough to not refresh a page?
body: <p>I have an jQuery accordion for a form on an internal company website. They seriously want to stick with their ASP.net technology (I know I'd bark at them if an intern could do that reasonably). </p>
  
  <p>Project description:  Creating a basic CRM form</p>
  
  <p>The first slide of the accordion has their basic input for recording contact information which will include a client we already have recorded. If the contact isn't already in the database and they try to use it, the accordion will move to the next slide and allow the person to fill out a form to record a new client. After that I compare the names to the database again, and show the user the similar names in a third accordion IF and ONLY IF results exist. (I know, redundant, but I want to save myself some duplicates, these are civil engineers they just put in what works as long as its not a bridge calculation) </p>
  
  <p>Actual Problem: ASP.net codebehind takes care of the datasearching and displaying (for now) and jQuery/Javascript/HTML moves the accordion around. Since I only want the accordion to open the last slide if there are results - how do I get enough information from the serverside check of the database to do accordion movements conditionally, while still avoiding full postbacks and refreshes?</p>
  
  <p>Also, I realize this is a little more cosmetic, but right now I do fadeins/fadeouts with jquery - I don't want this to look like jerky 1995 webpage loading with lots of refreshes. So keeping that to a minimum would be more than fantastic.</p>
  
  <p>client.aspx (some of the javascript)</p>
  
  <pre><code>function pageLoad() {
          $("#dymslide").hide();
          var active = $("#accordion").accordion("option", "active");
          if (active = 2) {
              $("#dymslide").show(750);
          }
      }
      $(document).ready(function () {
          $("#ncfslide").hide();
          $("#dymslide").hide();
          $("#accordion").accordion({
              autoHeight: false,
              navigation: true,
              collapsible: true
          });
          $("#saveButton").click(function () {
              $("#dymslide").bind('load', function () {
                  $("#Label2").bind('load', function () {
                      var isVisible = $("#Label2")[0].style.display == "block";
                      if (isVisible) {
                          $("#accordion").accordion("activate", 2);
                      }
                  });
              });
          });
      });
  </code></pre>
  
  <p>client.aspx</p>
  
  <pre><code>&lt;center&gt;
                  &lt;p&gt;
                      &lt;br /&gt;
                      &lt;asp:Label ID="tf" runat="server"&gt;&lt;/asp:Label&gt;
                      &lt;asp:Button ID="saveButton" runat="server" Text="Save Contact"/&gt;
                      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                      &lt;asp:Button ID="cancelButton" runat="server" Text="Cancel" /&gt;
                  &lt;/p&gt;
              &lt;/center&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;h3&gt;
          &lt;a href="#dym" name="dym"&gt;Did you mean?&lt;/a&gt;
      &lt;/h3&gt;
      &lt;div&gt;
          &lt;div id="dymslide"&gt;
              &lt;asp:UpdatePanel ID="up" runat="server"&gt;
                  &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="saveButton" EventName="Click" /&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;p&gt;
                          &lt;asp:Label ID="Label2" runat="server"&gt;&lt;/asp:Label&gt;
                      &lt;/p&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>client.aspx.vb</p>
  
  <pre><code>Protected Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
      If LikeNames(fNameValue.Text, lNameValue.Text) Then
          Label2.Style("display") = "block"
      Else
          Label2.Attributes.Add("display", "none")
  
      End If
  
  End Sub
  </code></pre>
  
  <p>And yes I know - I won't be displaying results in a simple label eventually but as I haven't even gotten these basic things working I don't think I have to worry about it quite yet.</p>