protected override void OnPreRender(EventArgs e)
{
EnsureDataBound();
base.OnPreRender(e);
// Set the overflow to hidden to prevent any growth from
// showing initially before it is hidden by the script if
// we are controlling the height
if(AutoSize != AutoSize.None) {
Style[HtmlTextWriterStyle.Overflow] = "hidden";
Style[HtmlTextWriterStyle.OverflowX] = "auto";
}
// Apply the standard header/content styles, but allow the
// pane's styles to take precedent
foreach(var pane in Panes) {
if(pane.HeaderCssClass == HeaderSelectedCssClass)
pane.HeaderCssClass = String.Empty;
if(!String.IsNullOrEmpty(HeaderCssClass) && String.IsNullOrEmpty(pane.HeaderCssClass))
pane.HeaderCssClass = HeaderCssClass;
if(!String.IsNullOrEmpty(ContentCssClass) && String.IsNullOrEmpty(pane.ContentCssClass))
pane.ContentCssClass = ContentCssClass;
}
// Get the index of the selected pane, or use the first pane if we don't
// have a valid index and require one. (Note: We don't reset the SelectedIndex
// property because it may refer to a pane that will be added dynamically on the
// client. If we need to start with a pane visible, then we'll open the first
// pane because that's the default value used on the client as the SelectedIndex
// in this scenario.)
var index = AccordionExtender.SelectedIndex;
index = ((index < 0 || index >= Panes.Count) && AccordionExtender.RequireOpenedPane) ? 0 : index;
// Make sure the selected pane is displayed
if(index >= 0 && index < Panes.Count) {
var content = Panes[index].ContentContainer;
if(content != null)
content.Collapsed = false;
}
}