Accordion可以包括多个Pane,每次显示一个,其他的pane折叠起来。Accordion中包含多个Accordionpane来实现其功能。
每个accordionpane包含使用模版的标题和内容。Seleced属性保证postback之后,仍然使展开的pane可见。
The Accordion is a web control that allows you to provide multiple panes and display them one at a time. It is like having several CollapsiblePanels where only one can be expanded at a time. The Accordion is implemented as a web control that contains AccordionPane web controls. Each AccordionPane control has a template for its Header and its Content. We keep track of the selected pane so it stays visible across postbacks.
It also supports three AutoSize modes so it can fit in a variety of layouts.
AutoSize属性,None 无限制,可能导致页面其他部分因为Accordion大小的改变而移动;Limit 受限的,accordion不会超过指定的Height,如果内容太多pane会显示滚动条;Fill 固定大小,内容放大或缩小到指定的大小。
The Accordion is written using an extender like most of the other extenders in the AJAX Control Toolkit. The extender expects its input in a very specific hierarchy of container elements (like divs), so the Accordion and AccordionPane web controls are used to generate the expected input for the extender. The extender can also be used on its own if you provide it appropriate input.
The Accordion can also be databound. Simply specify a data source through the DataSource or DataSourceID properties and then set your data items in the HeaderTemplate and ContentTemplate properties.
Accordion可以使用数据绑定。指定DataSource 或者 DataSourceID 属性,然后设置HeaderTemplate 和ContentTemplate即可。
<ajaxToolkit:Accordion ID="MyAccordion" runat="Server" SelectedIndex="0" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" AutoSize="None" FadeTransitions="true" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false" SuppressHeaderPostbacks="true"> <Panes> <ajaxToolkit:AccordionPane HeaderCssClass="accordionHeader" ContentCssClass="accordionContent"> <Header> . . . </Header> <Content> . . . </Content> </ajaxToolkit:AccordionPane> . . . </Panes> <HeaderTemplate>...</HeaderTemplate> <ContentTemplate>...</ContentTemplate> </ajaxToolkit:Accordion>