Solved

How to change Accordion Pane Header Titles Dynamically

Posted on 2008-09-30
1
3,038 Views
Last Modified: 2012-05-05
I have a listbox of names in an AJAX Accordion Pane. The first pane's title is "SELECT EMPLOYEE". When they select an employee, i would like to change the title of that pane to listbox1.selectedvalue.tostring.
AccordionPane2.Page.Title = ListBox1.SelectedValue.ToString doesn't seem to work!

Open in new window

0
Comment
Question by:wrwiii12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 22612374
Hi,

Problem is, the accordion pane does not have a title element. What You are accessing in your code is actually the System.Web.UI.Page.Title element, which makes no sence. What You need to do is to add a label for instance to the header template container of the accordion pane and reference that label and update it's text property from code behind in your ListBox.SelectedIndexChanged event. Please refer to the attached code snippet for a working example.

/Carl.
AccordionPage.aspx:
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AccordionPage.aspx.vb" Inherits="AccordionPage" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Accordion Page</title>
    <script language="javascript" type="text/javascript">
    </script>
    <style type="text/css">
        .Accordion
        {
            width: 250px;
            background-color: Silver;
            color: Black;
            font-family: Trebuchet MS;
            font-size: 10pt;
            border: solid 1px Black;
        }
        .AccordionPaneHeader 
        {
            background-color: Silver;
            padding: 3px 3px 3px 3px;
            border-top: solid 1px Black;
            border-bottom: solid 1px Black;
        }
        .SelectedAccordionPaneHeader 
        {
            background-color: Gray;
            font-weight: bold;
            padding: 3px 3px 3px 3px;
            border-top: solid 1px Black;
            border-bottom: solid 1px Black;          
        }
        .AccordionPaneContent 
        {
            padding: 3px 3px 3px 3px;
        }
        .ListBox
        {
            width: 180px;
            background-color: Silver;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">        
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
            <ContentTemplate>
                 <cc1:Accordion ID="Accordion1" FadeTransitions="true" TransitionDuration="250" runat="server" CssClass="Accordion" HeaderCssClass="AccordionPaneHeader" ContentCssClass="AccordionPaneContent" HeaderSelectedCssClass="SelectedAccordionPaneHeader" >
                    <Panes>
                        <cc1:AccordionPane ID="Pane1" runat="server">
                            <Header>
                                <asp:Label ID="lblHeader1" runat="server" Text="SELECT EMPLOYEE" />
                            </Header>
                            <Content>
                                <asp:ListBox ID="ListBox1" runat="server" CssClass="ListBox" AutoPostBack="true">
                                    <asp:ListItem Value="Person One" Text="Person One" />
                                    <asp:ListItem Value="Person Two" Text="Person Two" />
                                    <asp:ListItem Value="Person Three" Text="Person Three" />
                                    <asp:ListItem Value="Person Four" Text="Person Four" />
                                    <asp:ListItem Value="Person Five" Text="Person Five" />
                                </asp:ListBox>
                            </Content>
                        </cc1:AccordionPane>
                        <cc1:AccordionPane ID="Pane2" runat="server">
                            <Header>
                                <asp:Label ID="lblHeader2" runat="server" Text="SELECT LOCATION" />
                            </Header>
                            <Content>
                                <asp:ListBox ID="ListBox2" runat="server" CssClass="ListBox" AutoPostBack="true">
                                    <asp:ListItem Value="Branch Office 1" Text="Branch Office 1" />
                                    <asp:ListItem Value="Branch Office 2" Text="Branch Office 2" />
                                    <asp:ListItem Value="Branch Office 3" Text="Branch Office 3" />
                                    <asp:ListItem Value="Branch Office 4" Text="Branch Office 4" />
                                    <asp:ListItem Value="Branch Office 5" Text="Branch Office 5" />
                                </asp:ListBox>
                            </Content>
                        </cc1:AccordionPane>
                    </Panes>
                </cc1:Accordion>           
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
 
AccordionPage.asxp.vb:
 
Partial Class AccordionPage
    Inherits System.Web.UI.Page
 
    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        lblHeader1.Text = ListBox1.SelectedValue.ToString
    End Sub
 
    Protected Sub ListBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
        lblHeader2.Text = ListBox2.SelectedValue.ToString
    End Sub
End Class

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question