How to change Accordion Pane Header Titles Dynamically

Posted on 2008-09-30
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

Question by:wrwiii12
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

carlnorrbom earned 500 total points
ID: 22612374

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.

<%@ 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" "">
<html xmlns="">
<head runat="server">
    <title>Accordion Page</title>
    <script language="javascript" type="text/javascript">
    <style type="text/css">
            width: 250px;
            background-color: Silver;
            color: Black;
            font-family: Trebuchet MS;
            font-size: 10pt;
            border: solid 1px Black;
            background-color: Silver;
            padding: 3px 3px 3px 3px;
            border-top: solid 1px Black;
            border-bottom: solid 1px Black;
            background-color: Gray;
            font-weight: bold;
            padding: 3px 3px 3px 3px;
            border-top: solid 1px Black;
            border-bottom: solid 1px Black;          
            padding: 3px 3px 3px 3px;
            width: 180px;
            background-color: Silver;
    <form id="form1" runat="server">        
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
                 <cc1:Accordion ID="Accordion1" FadeTransitions="true" TransitionDuration="250" runat="server" CssClass="Accordion" HeaderCssClass="AccordionPaneHeader" ContentCssClass="AccordionPaneContent" HeaderSelectedCssClass="SelectedAccordionPaneHeader" >
                        <cc1:AccordionPane ID="Pane1" runat="server">
                                <asp:Label ID="lblHeader1" runat="server" Text="SELECT EMPLOYEE" />
                                <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" />
                        <cc1:AccordionPane ID="Pane2" runat="server">
                                <asp:Label ID="lblHeader2" runat="server" Text="SELECT LOCATION" />
                                <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" />
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


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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