Skip to content Skip to sidebar Skip to footer

Keep Jquery Accordion Open After Refresh

I made an asp.net web site in which i put a jquery accordion. My Problem is that after a postback or a refresh, the current accordion pane closes and the page resets every things.

Solution 1:

The problem you are facing is because after postback asp.net refreshes the whole page. Solutions for that would be:

  1. Use UpdatePanel for the places you want to update http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel(v=vs.110).aspx that will prevent the PostBack from refreshing your page
  2. Include information in the postback which accordion is currently open and open it
    • either from asp.net backend
    • or from javascript with ClientScriptManager.RegisterStartupScript(this.GetType(), "AKey", "MyFunction('paramToOpenTab');", true);

Solution 2:

Thanks it workes with UpdatePanel; This is the solution :

<divid="accordion-1"class="accordion-section-content"><asp:ScriptManagerEnablePartialRendering="true"ID="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"><ContentTemplate><tablestyle="width:100%; height: 600px;"border="1"><tr><td></td><td><asp:ButtonID="btnChercher"runat="server"Text="Chercher"onclick="btn_Chercher"></asp:Button></td></tr><tr><td>
                 Test 1</td><td><asp:ChartID="ChartDate"runat=server><Legends><asp:LegendAlignment="Center"Docking="Top"IsTextAutoFit="False"Name="Default"LegendStyle="Row" /></Legends><Series><asp:SeriesName="Nombre documents"></asp:Series></Series><ChartAreas><asp:ChartAreaName="ChartArea1"></asp:ChartArea></ChartAreas></asp:Chart></td></tr><tr><td>
                    Test 3</td><td><asp:ChartID="ChartEtat"runat=server><Legends><asp:LegendAlignment="Center"Docking="Top"IsTextAutoFit="False"Name="Default"LegendStyle="Row" /></Legends><Series><asp:SeriesName="Etat"></asp:Series></Series><ChartAreas><asp:ChartAreaName="ChartAreaHlm"></asp:ChartArea></ChartAreas></asp:Chart></td></tr><tr><td>
                    Test 5</td><td><asp:ChartID="ChartFormulaire"runat=server><Legends><asp:LegendAlignment="Center"Docking="Top"IsTextAutoFit="False"Name="Default"LegendStyle="Row" /></Legends><Series><asp:SeriesName="Formulaire"></asp:Series></Series><ChartAreas><asp:ChartAreaName="ChartAreaFormulaire"></asp:ChartArea></ChartAreas></asp:Chart></td></tr></table></ContentTemplate></asp:UpdatePanel></div>

Thank you n0mercy

Post a Comment for "Keep Jquery Accordion Open After Refresh"