Set Ajax Toolkit Accordion Panes all closed on load




Set Ajax Toolkit Accordion Panes all closed on load
As you know when you use the accordion element of the Ajax Toolkit, one of the panes is automatically open on load. Well there is a way around this, simply add the below to your page loading sub:
  1. MyAccordion.selectedindex = "-1"  
An example of this in place would be:
  1. Private Sub Page_Load()   
  2.      If Not Page.IsPostBack Then  
  3.          BindData()   
  4.      End If  
  5. End Sub  
  6.   
  7. Private Sub BindData()   
  8.         MyAccordion.selectedindex = "-1"  
  9. End Sub  
You will also need to add the below code to your accordion:
  1. requireopenedpane="false"  
It should look something like this then:
  1. <cc1:accordion id="MyAccordion" runat="server"    
  2. headercssclass="accordianheader" cssclass="accordian"  
  3.  contentcssclass="accordianitem" requireopenedpane="false" />  


8 people like this article, click here to say you like this article too (8)
Send a link to this page via email Send a link to this page