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:

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" />

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*