Follow the easy steps below to create your solution.
Start your Visual Studio 2005 IDE.
Choose Create Web Site from the menu.
In this sample application we will use the Visual Basic language for the
the solution CollapsiblePanelSample.
Choose ASP.NET AJAX Control Toolkit Web Site.
Choose File System in the location box.
Click ok to create the project.
Visual Studio will create your project with a Default.aspx
page and most likely a readme.txt. Go ahead and get rid of the latter file.
Open Default.aspx page in design view.
noticed that there is a control on the page already called script manager.
(Well, AJAX is really a script based implementation of the language
Microsoft ASP.NET AJAX pages. By default, the Script Manager control registers
the script for the Microsoft AJAX Library with the page. This enables client
script to use the type system extensions and to support features such as
partial-page rendering and Web-service calls.
you have to fill your page with some text. In order to do so, take Listing 1
and copy and paste it many times inside the div tag within the default.aspx
page when in source mode.
a new item in the solution of type Style Sheet and leave the default name.
1 contains the style sheet content that should be placed inside the file. You
can copy and paste directly.
Listing 1- Style Sheet Content for
to the source mode, and click and drop the style sheet file into the header section
of the default web form in order to be able to reference it.
drag two panels from the standard toolbox and drop them on the page.
the first panel PnlTitle and delete the height and width specs then create a
CssClass tag with value collapsePanelHeader like in listing 2.
Listing 2- Title Panel and Content Panel Format
<asp:Panel ID="PnlTitle" runat="server" CssClass="collapsePanelHeader">
<asp:Panel ID="PnlContent" runat="server" CssClass="collapsePanel">
the second panel PnlContent and delete the height and width specs then create a
CssClass tag with value collapsePanel like in the above listing.
the title panel add an asp image standard control (it is necessary to use the
image asp control in order to be able to control it afterwards). Make the image
url point to an image that you create with a down arrow (call the image
collapse_blue.jpg to be able to use it later). Also, create another image with
an up arrow (call the image expand_blue.jpg to be able to use it later).
19. After the image
control, add a text in bold that says: Who Am I?
20. Now drag a label and make the text tag Show Details (…)
fill the content panel with some information about yourself in any html format.
the cursor after the script manager html end tag. From the Toolbox drag a Collapsible
Panel control and set the properties as specified in Listing 3.
Listing 3- Collapsible Panel Extender specs
runat="server" TargetControlID="PnlContent" ExpandControlID="PnlTitle"
CollapsedText="Show Details (...)" ExpandedText="Hide Details (...)"
note that some of these properties cannot be specified using the normal
properties window. The target control ID specifies the control to collapse and
extend (the content panel in our case).
Expand Control ID specifies the control that is going to control the expansion
(the title panel in our case).
Collapse Control ID specifies the control that is going to collapse the panel
(the title panel in our case).
note that you can specify two different controls to collapse and expand.
Text Label ID specifies that label that is going change its text caption when
the user collapses or expands the panel.
same description applies the Image Control ID, but the image is going to
Collapsed Text tag specifies the text that should appear when the panel is
Expanded Text tag specifies the text that should appear when the panel is
Expanded Image tag specifies the image to display when the panel is expanded.
Collapsed Image tag specifies the image to display when the panel is collapsed.
Collapsed tag specifies the state of the content panel when the page loads.
Suppress Post Back tag specifies that when expanding the panel, there should be
no posting to the server or not. In our case and since our content is fixed and
not changing, we did set this property to true.