Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I persist the state of slideToggle at post back?
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload