Topic: Adding an AJAX Collapsible Panel
Description: This tutorial/topic shows you how to add an AJAX CollapsiblePanelExtender to your ASP.Net page.
Notes: It is assumed you have already AJAX enabled your web project.

1.  You must have the following DOCTYPE declaration on your page or in your MasterPage.

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

     If implementing in older pages, you might need to use this DOCTYPE:

DOCTYPE html PUBLIC "-//W3C\\DTD XHTML 1.1//EN" "">

2.  Add an AJAX script manager to the top of your ASP.Net page, just below your <asp:Content> element.

3.  Next create a <div> section to put the following sections into.

4.  Add the following <div> and <panel> elements for the content you want to make collapsible:

<div id="ExpandableContent" class="collapseTargetPanel">
   <asp:Panel ID="ContentPanel" runat="server" Height="0px" Width="100%">
         Whatever you want for content

5.  Add the following section to create the Collapsible Panel Title bar.  Put this just above the panel you created in step 4.

<div id="ExpandableTitleBar" class="collapsePanel">
   <asp:Panel ID="TitlePanel" runat="server" Height="23px" Width="100%">
      <div style="padding:5px; cursor:hand; vertical-align:middle;">
         <div style="float:left; vertical-align:middle;">
            <asp:Image ID="ImageToControl" runat="server" ImageUrl="Images/expand.jpg"/>
         <div style="float:left;">
            What's New...
         <div style="float:right; margin-left:20px">
            <asp:Label ID="TextToControl runat="server" Text="">asp


6.  Add the following section to create the Collapsible Panel Extender.  Put this just above the section you created in step 5.



7.  You can use the following CSS classes to help define your content:


   font-size: 0.8em;


8.  Sometimes, your CSS will not work with the new AJAX Controls/Extenders.  To have your markup controlled by CSS, you will need to do the following:

     a.  Create a "Theme" folder.
     b.  Add a folder to the "Theme" folder called "Default".
     c.  Add a "Default" stylesheet to the folder in step 8b.
     d.  Within the stylesheet, add your css elements.
     e.  On your page where you are adding the AJAX controls, you'll need to add the theme in the PreInit method for the page.  See example below:


 Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
   Page.Theme = "Default"
End Sub


protected void Page_PreInit(object sender, EventArgs e)
   Page.Theme = "Default";

     f.  In your <head> element on your page, make sure you add runat="server"
     g.  Add the class attribute to your element tabs to get the css formatting.