title: How can I persist the state of slideToggle at post back?
body: <p>I want jQuery <a href="http://api.jquery.com/slideToggle/" rel="nofollow"><code>slideToggle()</code></a> to persist it's state. By default when the page loads it is collapsed. For the <code>&lt;div&gt;</code> that has the slideToggle() applied there is an <code>asp:</code> button, and when clicked some operation is performed, but probably a page post back occurs.</p>
  
  <p>If the page is refreshed the initial state of the <code>&lt;div&gt;</code> should be visible if the user had previously clicked the <code>slideToggle()</code>. Similarly if the user collapses the <code>&lt;div&gt;</code> again, when the page is refreshed (either F5 or a post back) then the <code>&lt;div&gt;</code> should once again be initially collapsed.</p>
  
  <p>So basically I want to know how to persist the state of slideToggle() at post back? Here is the code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $(".flip").click(function() {
              $(".panel").slideToggle("slow");
          });
      });
  &lt;/script&gt;
  
  &lt;div&gt;
      &lt;div class="panel"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;First Name:&lt;/td&gt;
                  &lt;td&gt;&lt;asp:TextBox runat="server" Text=""&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Last Name:&lt;/td&gt;
                  &lt;td&gt;&lt;asp:TextBox ID="LastName" runat="server" Text=""&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Email:&lt;/td&gt;
                  &lt;td&gt;&lt;asp:TextBox ID="Email" runat="server" Text=""&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Role Name:&lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="RoleName" runat="server"&gt;
                          &lt;asp:ListItem Text="Select a role" Enabled="true" Value=""&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="DC" Value="DC"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="ST" Value="ST"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="AD" Value="AD"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="CA" Value="CA"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GSP" Value="GSP"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GDC" Value="GDC"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GST" Value="GST"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GAD" Value="GAD"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GCA" Value="GCA"&gt; &lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="GSP" Value="GSP"&gt; &lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;asp:Button ID="Addparticipant" runat="server" Text="Add Participant" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;p class="flip"&gt;Show/Hide Panel&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The ASP code:</p>
  
  <pre><code>Protected Sub Addparticipant_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Addparticipant.Click
      Response.Write("Hi it work yaar")
  End Sub
  </code></pre>