Wednesday, March 21, 2012

NEED HELP! CollapsiblePanelExtender after callback still open?

Hello Community, I use since short AJAX. My menu/navigation I designed with CollapsiblePanelExtender, also all this dynamically. I get myself on the left of and headings from the data base and provide myself then the panels, left and images of everything dynamically. Everything marvelously and super. Now know it surely everything our customers --> "why that again opened unfold? It closed a while ago!". Therefore I must store the status somehow, expended or collapsed. I have one blog found where it am in such a way made:

1static string _topPanelCollapsed_ClientState;23protected void Page_Load(object sender, EventArgs e)4{5if (IsPostBack)6 _topPanelCollapsed_ClientState =7 CollapsiblePanelExtender1.ClientState ;8else9 CollapsiblePanelExtender1.ClientState =10 _topPanelCollapsed_ClientState;

For a panel that could be able be done, but as I get now so dynamically that it functions with my n-Panlels? Unfortunately there is none however with panels "onClick" Event and on the Event of the CollapsiblePanelExtender cannot one not access. I am grateful over all solutions.

PLEASE HELP ME!

i'm to despair!!!

thx for your answers!

Please post some code, maybe then we can help you more easily.

(Use the top-right button to insert code when you reply, thanks!)

Wim


69void PreparedMenu()70 {71 XmlDocument doc =new XmlDocument();72 doc.LoadXml(xmlText);7374 XmlElement root = doc.DocumentElement;7576 XmlNodeList XmlMainNode = doc.GetElementsByTagName("MainMenu");7778// MainMenuPanel erstellen79for (int i = 0; i < XmlMainNode.Count; i++)80 {81 XmlAttributeCollection xmlattribute = XmlMainNode[i].Attributes;82string titel = xmlattribute.GetNamedItem("Titel").Value;83string link = xmlattribute.GetNamedItem("Link").Value;84string pic ="";85if (xmlattribute.GetNamedItem("Pic") !=null)86 pic = xmlattribute.GetNamedItem("Pic").Value;87 Panel subMenuPanel =null;88string currentSubPanel ="";8990 pnlMenu.Controls.Add(getNewMainPanel(titel, link, pic));9192foreach (XmlNode subnodein root.ChildNodes.Item(i).ChildNodes)93 {94 XmlAttributeCollection xmlSubAttribute = subnode.Attributes;95string subtitel = xmlSubAttribute.GetNamedItem("SubTitel").Value;96string sublink = xmlSubAttribute.GetNamedItem("SubLink").Value;97 HtmlGenericControl htmblBreak =new HtmlGenericControl("br");9899// Prüft ob ein Subpanel für diesen Menüpunkt existiert.100if (subMenuPanel ==null)101 {102 subMenuPanel =new Panel();103104// Eigenschaften des Panels setzen105 subMenuPanel.ID ="Sub" + titel;106107// aktueller Subpanel108 currentSubPanel = subMenuPanel.ID;109 subMenuPanel.CssClass ="collapsePanel";110 subMenuPanel.Controls.Add(getNewLink(subtitel, sublink));111 subMenuPanel.Controls.Add(htmblBreak);112 }113else114 {115 subMenuPanel.Controls.Add(getNewLink(subtitel, sublink));116 subMenuPanel.Controls.Add(htmblBreak);117 }118 }119// Prüft ob ein dummy Panel erstellt werden muss.120if (currentSubPanel =="")121 {122 Panel emptyPanel =new Panel();123 emptyPanel.ID = titel +"Empty";124 currentSubPanel = emptyPanel.ID;125 emptyPanel.Height = 0;126127 pnlMenu.Controls.Add(emptyPanel);128 }129130// Prüft ob es ein SubMenuPanel hat.131if (subMenuPanel !=null)132 {133 pnlMenu.Controls.Add(subMenuPanel);134 subMenuPanel =null;135 }136137 pnlMenu.Controls.Add(getNewAjaxcollapsPanel(titel, currentSubPanel, link));138 }139 }140141protected CollapsiblePanelExtender getNewAjaxcollapsPanel(string mainpanel,string subpanel,string link)142 {143//Ajax Controll erstellen für jeden MainMenu Eintrag144 collapsPanel =new CollapsiblePanelExtender();145 collapsPanel.ID ="pnlEx" + mainpanel;146 collapsPanel.TargetControlID = subpanel;147 collapsPanel.ExpandControlID = mainpanel;148 collapsPanel.CollapseControlID = mainpanel;149 collapsPanel.Collapsed =true;150 collapsPanel.SuppressPostBack =false;151 collapsPanel.EnableViewState =true;152153return collapsPanel;154 }155156protected Panel getNewMainPanel(string titel,string link,string picture)157 {158// Tempor?res Panel erstellen159 Panel mainMenuPanel =new Panel();160161// Eigenschaften des Panels setzen162 mainMenuPanel.ID = titel;163 mainMenuPanel.CssClass ="collapsePanelHeader";164 mainMenuPanel.EnableViewState =true;165166 HyperLink mainLink = getNewLink(titel, link);167 mainLink.CssClass ="headerMenu";168169// Image erstellen170if (picture !="")171 {172 Image mainImage =new Image();173 mainImage.ImageUrl = picture;174 mainImage.Height = 24;175 mainImage.Width = 24;176 mainMenuPanel.Controls.Add(mainImage);177 }178179// Controls dem Panel hinzufügen180 mainMenuPanel.Controls.Add(mainLink);181182return mainMenuPanel;183 }184185protected HyperLink getNewLink(string name,string url)186 {187 PostBackOptions test =new PostBackOptions(this);188 test.ActionUrl = url;189190// Menülink erstellen191 HyperLink aMenuLink =new HyperLink();192 aMenuLink.Text = name;193 aMenuLink.NavigateUrl = url;194195return aMenuLink;196 }197}

Well thats my code.

example menu
--------
- home
- menupoint1
- menupoint2
- menupoint3

click on menupoint1 --> the content of menupoint1 load to the contentplaceholder

after the click the menu looks like (after callback)

- home
- menupoint1
- menupoint2
- menupoint3

but I would like so (the panels that i clicked remain open)

- home
- menupoint1
submenupoint1
submenupoint2
- menupoint2
- menupoint3


i hope it know which I mean ;)

thx for help!


No comments:

Post a Comment