Advertisement

03.12.2008 at 08:31PM PDT, ID: 23237472
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

AJAX Accordion Control - How to set selected index of an accordion within another accordion?

Asked by kmoloney in Programming for ASP.NET, Visual Studio, .NET Framework 2.x

Tags: ,

I have an asp.net web application being developed in VS2005 (Visual Basic), which uses an Accordion control as the navigating control (left banner) of a master page.  The default behavior of an accordion control  when used in a master page is to re-open the 0-index accordion pane on postback.  I wanted to keep the active pane open, so that the user wouldn't have to keep on clicking on the same pane header over and over to see the hyperlinks in the content section of that pane.

I kind of solved this problem (see Q_23218319) by placing code in the content page (see sample code A in Code Snippet below).  "AccordionLBanner" is the name of the accordion.  When the page loads, it simply uses the findcontrol method of the master (page) to set the selectedindex to the index of the accordion pane from which it was called.

NOW it gets really fun!!  The content of an accordion pane can contain whatever html we want, including other Accordion Controls.  So, within one of the accordion panes in "AccordionLBanner," I have another accordion control, which itself has a couple of its own panes, and their own hyperlinks.

For some reason, while the master.Findcontrol method works fine for the main accordion and its immediate sub-panes, it doesn't seem to work for an accordion control within an accordion control.    See sample Code B.

So, how do I go about doing this?  Is it possible?  Why doesn't master.findcontrol find the embedded accordion within the accordion?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
SAMPLE CODE A:  KEEPING THE 'ACTIVE' BANNER OPEN
=================================================
 
Imports AjaxControlToolkit
 
Partial Class UnderConstruction
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim mpAccordion As Accordion
        mpAccordion = CType(Master.FindControl("AccordionLBanner"), Accordion)
        mpAccordion.SelectedIndex = clsShared.apID._EVENTS  '// in this case, = 2
 
    End Sub
End Class
 
SAMPLE CODE B:  master.findcontrol DOESN'T RETURN THE SECOND-LEVEL ACCORDION CONTROL...
=========================================
 
Imports AjaxControlToolkit
 
Partial Class Services_Geriatric
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim mpAccordion As Accordion
        '   ============================================================
        '   NOTE:  THIS IS THE PAGE_LOAD CODEBEHIND FOR A PAGE CALLED Geriatric.aspx.
        '   mpAccordion returns NOTHING.
        '====================================================================
        '   
        mpAccordion = CType(Master.FindControl("ac_Services"), Accordion)
        mpAccordion.SelectedIndex = clsShared.apServices._SHARED    '// in this case, 3
 
    End Sub
End Class
 
SAMPLE CODE C:  MASTER PAGE STRUCTURE (SOME CODE OMITTED)
=========================================================
 
<cc1:Accordion 
                ID="AccordionLBanner" 
                runat="server" 
                fadetransitions=true 
                framespersecond="60" 
                TransitionDuration="250" 
                AutoSize="none" SuppressHeaderPostbacks=true
                HeaderCssClass="accordionHeader" 
                ContentCssClass="accordionContent">
                
                
                <Panes>
                
                <cc1:AccordionPane ID="ap_Home" runat="server">
                    <Header>
                        
                            Home
                        
                    </Header>
                    
                    <Content>
                        <asp:HyperLink ID="hypHome" runat="server" NavigateUrl="~/Default.aspx">Home</asp:HyperLink><br />
                        <asp:HyperLink ID="hypMission" runat="server" NavigateUrl="~/Mission.aspx">Mission Statement</asp:HyperLink><br />
                        <asp:HyperLink ID="hypHistory" runat="server" NavigateUrl="~/History.aspx">History</asp:HyperLink><br />
                        <asp:HyperLink ID="hypEligibility" runat="server" NavigateUrl="~/Eligibility.aspx">Eligibility</asp:HyperLink><br />
                        <asp:HyperLink ID="hypAccreditations" runat="server" NavigateUrl="~/Accreditation.aspx">Accreditations</asp:HyperLink><br />
                        <asp:HyperLink ID="hypTestimonial" runat="server" NavigateUrl="~/testimonial.aspx">Testimonials</asp:HyperLink>
                        
                        
                        
                        
 
                    </Content>
                </cc1:AccordionPane>
                    
                
 
.
.
.
                
                <cc1:AccordionPane 
                    ID="Services"
                       runat="server">
                    <Header>
 
                            Services
 
                    </Header>
                    
                    <Content>
                        <cc1:Accordion 
                            ID="ac_Services"
                            runat="server"
                            fadetransitions=true
                            framespersecond="60" 
                            TransitionDuration="250"
                            AutoSize="none" suppressheaderpostbacks=true
                            HeaderCssClass="accordionHeader" 
                            ContentCssClass="accordionContent">
                        <Panes>
                            
                            <%--MI SERVICES SUB-PANE--%>
                            
                            <cc1:AccordionPane
                                ID="ap_MI_Services"
                                runat="server">
                                <Header>
                                    MI Services
                                </Header>
                                <Content>
                                
                                
                                    <asp:HyperLink ID="hypAct" runat="server" NavigateUrl="~/Services/ACT.aspx">ACT</asp:HyperLink><br />
                                    <asp:HyperLink ID="hypCSM" runat="server" NavigateUrl="~/Services/CaseManagement.aspx">Case Management</asp:HyperLink><br />
                                    <asp:HyperLink ID="hypDBT" runat="server" NavigateUrl="~/Services/DBT.aspx">DBT</asp:HyperLink><br />
                                    
    
 
                                    
                                                   
                                </Content>
                            </cc1:AccordionPane>
                            
                            <%--DD SERVICES SUB-PANE--%>
                            
                            <cc1:AccordionPane
                                ID="ap_DDServices"
                                runat="server">
                                <Header>
 
                                        DD Services
 
                                </Header>
                                <Content>
                                    <%--REMOVED FAMILY SERVICES LINE FOR NOW - REF IS STILL THERE--%>
                                    <%--<a href=/TTI2008/Services/FamilyServices.aspx>Family Services</a><br />--%>
                                    
                                    <asp:HyperLink ID="hypSC" runat="server" NavigateUrl="~/Services/SupportsCoordination.aspx">Supports Coordination</asp:HyperLink><br />
                                    <asp:HyperLink ID="hypReach" runat="server" NavigateUrl="~/Services/Reach.aspx">Project R.E.A.C.H.</asp:HyperLink>
                                                                        
                                    
 
                                </Content>    
                            </cc1:AccordionPane>
                            
                            <%--SUPPORT SERVICES SUB-PANE--%>
                            
                            <cc1:AccordionPane
                                ID="ap_SupportServices"
                                runat="server">
                                <Header>
 
                                        Support / Secondary Services
 
                                </Header>
                                <Content>
                                
                                    <asp:HyperLink ID=hypSSO runat="server" NavigateUrl="~/Services/SupportServicesOverview.aspx">Support Services Overview</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypGeriatric runat="server" NavigateUrl="~/Services/Geriatric.aspx">Geriatric</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypHousing runat="server" NavigateUrl="~/Services/Housing.aspx">Housing</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypOT runat="server" NavigateUrl="~/Services/OccupationalTherapy.aspx">Occupational Therapy</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypPsychoTherapy runat="server" NavigateUrl="~/Services/Psychotherapy.aspx">PsychoTherapy</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypGroupTherapy runat="server" NavigateUrl="~/Services/Psychotherapy.aspx">Group Therapy</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypResidential runat="server" NavigateUrl="~/Services/Residential.aspx">Residential Services</asp:HyperLink><br />
                                    <asp:HyperLink ID=hypClubhouse runat="server" NavigateUrl="~/Services/Clubhouse.aspx">Clubhouse (P.S.R.)</asp:HyperLink>
                                
 
                                    
                                </Content>    
                            </cc1:AccordionPane>
 
                        </Panes>
                        
                    
                    </cc1:Accordion>
                   </Content> 
               </cc1:AccordionPane>
            
           
.
.
.
  
           
            
            </Panes>
            </cc1:Accordion>
[+][-]03.12.2008 at 08:57PM PDT, ID: 21113230

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.12.2008 at 09:50PM PDT, ID: 21113418

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Visual Studio, .NET Framework 2.x
Tags: ASP.NET, VB (VS 2005), Internet Explorer 7, Firefox 2
Sign Up Now!
Solution Provided By: kmoloney
Participating Experts: 0
Solution Grade: A
 
 
[+][-]03.12.2008 at 09:52PM PDT, ID: 21113434

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628