title: ASP .NET C# - Programmatically expand/collapse AJAX accordion panes?
body: <p>Using .NET 3.5.</p>
  
  <p>How do I programmtically expand/collapse the panes contained within a AJAX accordion control?</p>
  
  <p>My page will have several accordions controls which I want to be able to mass expand/collapse with some buttons.</p>
  
  <p><strong>UPDATE1</strong></p>
  
  <p>My final code solution looks like this:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  function collapse_all(flag)
  {
  if(flag==true)
  {            
  var behavior = $get("&lt;%=Accordion1.ClientID%&gt;").AccordionBehavior;            
  behavior.set_SelectedIndex(-1);            
  }
  else
  {
  var behavior = $get("&lt;%=Accordion1.ClientID%&gt;").AccordionBehavior;            
  behavior.set_SelectedIndex(0);            
  }
  }    
  &lt;/script&gt;
  </code></pre>