In the Ajax accordion control, how to control the items that have been selected
The first item is always displayed when the accordion control is used. When different users display different items, how to control the items that you just clicked after returning them.
Below is the solution.
1) Save the folder name and the ID of the corresponding accordionpane of the project where each ASPX page is located. The main purpose of this step is to find accordionpane by the name of the folder where aspx is located.
2) after return, compare the folder name in the URL path with the saved value. The corresponding items are displayed.
The column is as follows:
1) Add the accordion control on the ASPX page. The source code is summarized as follows:
Project folders include:
2) map the project folder name of each ASPX page to accordionpane ID and save it.
// Define menu list
Private Static Idictionary < String , String > _ Menulist { Get ; Set ;}
Protected Void Page_load ( Object Sender, eventargs E)
{
/*
The menu list is in the format of <folder directory name, accordionpane ID>
The workflowdesigner folder of the following edge corresponds to accordionpane of apworkflow
*/
_ Menulist = New Dictionary < String , String > (){
{ " Workflowdesigner " , " Apworkflow " },
{ " Reporting " , " Apreporting " },
{ " Businessmanager " , " Apbusiness " },
{ " Message " , " Apmessage " },
{ " Organizationmanager " , " Aporgnization " },
{ " Systemlog " , " Apsystemlog " },
{ " Modulemanagemanet " , " Apmodule " }
};
Setmenueactiveindex ();
}
3 ) Get the folder name through the URL path, and find the items to be selected through comparison.
/// <Summary>
/// Set currently selected items
/// </Summary>
Private Void Setmenueactiveindex ()
{
String Currentpage = Getcurrenturl ();
If ( ! String . Isnullorempty (currentpage ))
{
String Currentpagelower = Currentpage. tolower ();
If (_ Menulist. Keys. Contains (currentpagelower ))
{
// Record Index
Int Index = - 1 ;
Foreach (VAR item In Mainmenue. PANES)
{
// Check whether the data is displayed
If (Item. Visible = True )
{
Index ++ ;
If (Item. Id. tolower () = _ Menulist [currentpagelower]. tolower ())
{
// Set the items to be displayed
Mainmenue. selectedindex = Index;
Break ;
}
}
}
}
}
}
/// <Summary>
/// Obtain the Directory Name of the page based on the current link.
/// </Summary>
/// <Returns> </returns>
Private String Getcurrenturl ()
{
String Resultstring = "" ;
String [] Splitlist = Request. url. absolutepath. Split ( ' / ' );
If (Splitlist. Length > 2 )
{
If ( ! String . Isnullorempty (splitlist [splitlist. Length - 2 ])
{
Resultstring = Splitlist [splitlist. Length - 2 ];
}
}
Return Resultstring;
}