title: Is there a way to set Ajax Accordion Index set to current view for an auto post back?
body: <p>I have an Ajax Accordion and I have the default selected index set to -1 so all panes are closed. Each pane has a few different controls and some do an auto post back, when the auto post back occurs, of course all the panes collapse.</p>
  
  <p>So is there away to have it on page load be set to selected index -1 and on post back have the selected index set to what it was before the post back?</p>
  
  <p>If I can clear up anything in my question let me know, as well as if there is any code snipits I could provide I will. -code behind is c#</p>
  
  <p>Thank you</p>
  
  <pre><code>//My Accordion
   &lt;ajaxtoolkit:accordion ID="MyAccordion" runat="Server" 
       HeaderCssClass="aHeader"  HeaderSelectedCssClass="aSelected"
       ContentCssClass="aContent" AutoSize="None" FadeTransitions="true"
       TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false" 
       SuppressHeaderPostbacks="true" Height="894px" style="margin-right: 23px" 
       Width="717px"&gt;
  
  //Page Load Event
   protected void Page_Load(object sender, EventArgs e)
      {
          if (ViewState["SelectedAccordionIndex"] == null)
          {
              MyAccordion.SelectedIndex = -1;
          }
          else
          {
              MyAccordion.SelectedIndex = (int)ViewState["SelectedAccordionIndex"];
          }
          if (!IsPostBack)
          {
              LoadPage();
          }
      }
      //drop down list set to auto post back
      protected void dropdownlist_SelectedInexChange(object sender, EventArgs e)
      {
          ViewState["SelectedAccordionIndex"] = MyAccordion.SelectedIndex;
      }
  </code></pre>