Set Ajax Toolkit Accordion Panes all closed on load

10 October 2009 , ,

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:

MyAccordion.selectedindex = "-1"

An example of this in place would be:

Private Sub Page_Load()
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Private Sub BindData()
MyAccordion.selectedindex = "-1"
End Sub

You will also need to add the below code to your accordion:

requireopenedpane="false"

It should look something like this then:

<asp:accordion id="MyAccordion" runat="server"
headercssclass="accordianheader" cssclass="accordian"
contentcssclass="accordianitem" requireopenedpane="false" />

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.