Set Ajax Toolkit Accordion Selected AccordionPane by ID




Set Ajax Toolkit Accordion Selected AccordionPane by ID
If you want to choose which AccodionPane is selected, you generally use the SelectedIndex command. However, if you want to select which AccordionPane is active by its ID and when you binded your data to your ajax accordion you set the ID of each AccordionPane you can use the below code:
 
This example is based on your accordion being called 'Accordion1'.
  1. 'strPaneID is the name of the pane you want to find and set active   
  2. Dim strPaneID As String = "Pane33"  
  3.   
  4. Dim i As Integer = 0   
  5. For Each accpane As AjaxControlToolkit.AccordionPane In Accordion1.Panes   
  6.     If (accpane.Visible = TrueThen  
  7.         If (accpane.ID = strPaneID) Then  
  8.             Accordion1.SelectedIndex = i   
  9.             Exit For  
  10.         End If  
  11.         i += 1   
  12.     End If  
  13. Next  


No one has said that they like article yet, be the first and click here (0)
Send a link to this page via email Send a link to this page