我有一个 Ajax Accordion,并且我将默认选定索引设置为 -1,因此所有窗格都已关闭。每个窗格都有几个不同的控件,有些会自动回发,当自动回发发生时,当然所有窗格都会崩溃。
那么是否可以在页面加载时将其设置为选定的索引 -1 并在回发时将选定的索引设置为回发之前的状态?
如果我可以澄清我的问题中的任何内容,请告诉我,以及是否有任何我可以提供的代码片段。-后面的代码是c#
谢谢
//My Accordion
<ajaxtoolkit:accordion ID="MyAccordion" runat="Server"
HeaderCssClass="aHeader" HeaderSelectedCssClass="aSelected"
ContentCssClass="aContent" AutoSize="None" FadeTransitions="true"
TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false"
SuppressHeaderPostbacks="true" Height="894px" style="margin-right: 23px"
Width="717px">
//Page Load Event
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["SelectedAccordionIndex"] == null)
{
MyAccordion.SelectedIndex = -1;
}
else
{
MyAccordion.SelectedIndex = (int)ViewState["SelectedAccordionIndex"];
}
if (!IsPostBack)
{
LoadPage();
}
}
//drop down list set to auto post back
protected void dropdownlist_SelectedInexChange(object sender, EventArgs e)
{
ViewState["SelectedAccordionIndex"] = MyAccordion.SelectedIndex;
}