Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
World Class ASP.NET Hosting - 3 Month Free Hosting, Click Here!
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » AJAX » Introduction of ASP.NET AJAX Toolkit - CollapsiblePanel

Introduction of ASP.NET AJAX Toolkit - CollapsiblePanel

The ASP.NET AJAX Toolkit is a new and powerful control in ASP.NET 2.0. It is designed for you to develop web applications that are more responsive, faster, and put fewer loads on the network, and in particular took .NET-based Ajax framework. This article will use one of ASP.NET AJAX Toolkit’s controls – CollapsiblePanel to demonstrate the benefit by using it.

Technologies: .NET 1.0/1.1, ASP.NET 1.0,Visual C# .NET
Total downloads : 1793
Total page views :  86884
Rating :
 5/5
This article has been rated :  5 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
CollapiblePanelDemo_AJAXV1.zip
 
Become a Sponsor



Abstract

The ASP.NET AJAX Toolkit is a new and powerful control in ASP.NET 2.0. It is designed for you to develop web applications that are more responsive, faster, and put fewer loads on the network, while using the .NET-based Ajax framework. This article will use one of ASP.NET AJAX Toolkit's controls - CollapsiblePanel to demonstrate the benefit by using it.

 

Introduction

AJAX!!! You have heard about it all the time. It is the latest buzz term for most of web programmers. AJAX is stands for Asynchronous JavaScript and XML.

 

It is an acronym for a couple of technologies that make it possible for developers to update a web page content at the control level without having to do a complete page refresh. For more details about ASP.NET AJAX please go to (http://ajax.asp.net/). The Codeplex team have made amazing controls that makes the life a lot easier for an ASP.NET programmer (more sleep and spending time with family & friends). These amazing controls are so called "ASP.NET AJAX Toolkit". 

 

System Requirements

The article assumes a familiarity with C#, as well as with using Visual Studio.NET 2005 to create ASP.NET applications. Elementary knowledge of ASP.NET AJAX extension library, Asynchronies Post back, ADO.NET and HTML would be beneficial but not absolutely necessary to fully understand the content of this article.

 

Advantage to use CollapsiblePanel

In the usual design way, if you want to show information between 2 objects. You would usually use Http Post as Figure 1 or Post back as Figure 2

 

Figure 1 HTTP Post between two pages

Figure 1 HTTP Post between two pages

 

Figure 2. Get detail by Post back

Figure 2. Get detail by Post back

 

Of course there is nothing wrong with these two designs, but what if we can make it better and faster?

Now let's see how CollapsiblePanel can make it better, with CollapsiblePanel, you don't have to worry about the table or controls are too long for the page. You can always collapse and expand to save space as Figure 3.

 

Figure 3. Easy to collapse and expand

Figure 3. Easy to collapse and expand

 

There is no page refresh when button click event fire up as Figure 4

 

Figure 4 no page refresh when Employee ID click

Figure 4 no page refresh when Employee ID click

 

Create CollapsiblePanel on ASP.NET page


**Please download the code and walkthrough it with each step


Step 1. Create ASP.NET project

 

Step 2. Ensure toolbox has AJAX Extensions tab.

 

Figure 5. AJAX Extensions in Toolbox

Figure 5. AJAX Extensions in Toolbox

If you dont see the AJAX Extensions in Toolbox, then you need to manually add new registry as below

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\ASP.NET AJAX 1.0.61025] @="c:\\Program Files\\Microsoft ASP.NET\\ASP.NET 2.0 AJAX Extensions\\v1.0.61025" by regedit

 

Step 3. Import AJAX Control Toolkit

Right click on Toolbox and select Add Tab as Figure 6.

 

Figure 6. Add new tab in Toolbox

Figure 6. Add new tab in Toolbox

 

Type "AJAX Control Toolkit" in the blank tab name as Figure 7.

 

Figure 7. Insert name to the blank new tab

Figure 7. Insert name to the blank new tab

 

Under .NET Framework Components tab, please click Browse to AjaxControlToolkit.dll from the directory you installed before as Figure 8.

 

Figure 8. Browse to AjaxControlToolkit.dll

Figure 8. Browse to AjaxControlToolkit.dll

 

Now you should see all the Ajax controls are display there, and then click OK as Figure 9.
 

Figure 9. AjaxControlToolkit controls

Figure 9. AjaxControlToolkit controls

 

You should have Ajax controls list in the toolbox ready to use.

 

Figure 10. AJAX Control Toolkit in Toolbox

Figure 10. AJAX Control Toolkit in Toolbox

 

Step 4. Drag and Drop ScriptManager to aspx page

To use most of ASP.NET AJAX Control, you need ScriptManager in the page as Figure 11.

  

Figure 11. Drag ScriptManager to asp.net page

Figure 11 Drag ScriptManager to asp,net page

 

Step 5. Create panel for Introduction title and panel for Introduction content

<asp:Panel ID="panelTitleIntroduction" runat="server" Height="25px" Width="405px">

<img id="imgBackgroundIntroduction" src="App_Themes/CollapsiblePanel/images/BackgroundIntroduction.png" />

</asp:Panel>

<asp:Panel ID="panelContentIntroduction" runat="server" Height="160px" Width="415px">

.....

<span style="font: 18px 'Lucida Grande', LucidaGrande, Verdana, sans-serif; color: #2d4c78;">The CollapsiblePanel is one of AJAX control in ASP.NET AJAX Control Toolkit. This tutorial combines CollapisblePanel and ASP.NET AJAX RC 1.0 to make amazing web application. It shows you how powerful in AJAX technology and what's advantage to use it. Hope you will like it</span>

.....

</asp:Panel>

 

Step 6. Create panel for Employee List title and panel for Employee List content

<asp:Panel ID="panelTitleEmployeeList" runat="server" Height="25px" Width="405px">

<img id="imgBackgroundEmployeeList" src="App_Themes/CollapsiblePanel/images/BackgroundEmployeeList.png" />

</asp:Panel>

<asp:Panel ID="panelContentEmployeeList" runat="server" Height="310px" Width="415px">

.....                   

<asp:DataGrid ID="dgNew" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" oneditcommand="dgNew_EditCommand" Width=100% >

.....

</asp:DataGrid>

</asp:Panel>

 

Step 7. Create panel for Employee Detail title and panel for Employee Detail content

 

<asp:Panel ID="panelTitleEmployeeDetail" runat="server" Height="25px" Width="405px">

<img id="imgBackgroundEmployeeDetail" src="App_Themes/CollapsiblePanel/images/BackgroundEmployeeDetail.png" />

</asp:Panel>

<asp:Panel ID="panelContentEmployeeDetail" runat="server" Height="300px" Width="415px">

.....

<table id="tblInformation" align="center" border="1" bordercolor="graytext" cellpadding="2" cellspacing="0" height="160" style="width: 300px; height: 170px" width="710" runat=server>

.....

</table>

</asp:Panel>


Step 8.  Drag 3 CollapsiblePanelExtenders to the form page


Figure 12. 3 CollapsiblePanelExtenders in the page.

Figure 12. 3 CollapsiblePanelExtenders in the page.

 

Step 9. Apply each CollapiblePanelExtender control with panels

<cc1:CollapsiblePanelExtender ID="cpeIntroduction" runat="server" TargetControlID="panelContentIntroduction" ExpandControlID="panelTitleIntroduction" CollapseControlID="panelTitleIntroduction" Collapsed="false"

ImageControlID="imgBackgroundIntroduction" ExpandedImage="App_Themes/CollapsiblePanel/images/HightLightIntroduction.png"

CollapsedImage="App_Themes/CollapsiblePanel/images/BackgroundIntroduction.png" SuppressPostBack="True" ScrollContents=true ></cc1:CollapsiblePanelExtender>

<cc1:CollapsiblePanelExtender ID="cpeEmployeeList" runat="server" TargetControlID="panelContentEmployeeList"

ExpandControlID="panelTitleEmployeeList" CollapseControlID="panelTitleEmployeeList" Collapsed="true"

ImageControlID="imgBackgroundEmployeeList" ExpandedImage="App_Themes/CollapsiblePanel/images/HightLightEmployeeList.png"

CollapsedImage="App_Themes/CollapsiblePanel/images/BackgroundEmployeeList.png" SuppressPostBack="True" ></cc1:CollapsiblePanelExtender>

<cc1:CollapsiblePanelExtender ID="cpeEmployeeDetail" runat="server" TargetControlID="panelContentEmployeeDetail"

ExpandControlID="panelTitleEmployeeDetail" CollapseControlID="panelTitleEmployeeDetail" Collapsed="true"

ImageControlID="imgBackgroundEmployeeDetail" ExpandedImage="App_Themes/CollapsiblePanel/images/HightLightEmployeeDetail.png"

CollapsedImage="App_Themes/CollapsiblePanel/images/BackgroundEmployeeDetail.png" SuppressPostBack="True"></cc1:CollapsiblePanelExtender>

 

In the Design View you should see those Ajax control as Figure 13

 

Figure 13. ScriptManager and 3 CollapsiblePanelExtenders on Design View

Figure 13. ScriptManager and 3 CollapsiblePanelExtenders on Design View

 

Now you should able to collapse and expand on those title panels as Figure 14. The only thing still need to modify is to avoid page refresh when click Employee ID hyper link.

 

Figure 14. The panels can be collapse and expand

Figure 14. The panels can be collapse and expand

 

Step 10. Add UpdatePanel to avoid page refresh

 

Figure 15 UpdatePanel in the page


Figure 15 UpdatePanel in the page

 

Step 11. Add ContentTemplate tag within UpdatePanel

 

Figure 16. Add ContentTemplate

Figure 16. Add ContentTemplate

 

Step 12. Wrap all 3 CollapsiblePanelExtender controls, 3 title panels and 3 content panels inside of <asp: UpdatePanel><ContentTemplate>

<asp:UpdatePanel ID="upEmployeeDetail" runat="server">

<ContentTemplate>...

<cc1:CollapsiblePanelExtender ID="cpeIntroduction" runat="server" >...

</cc1:CollapsiblePanelExtender>

<cc1:CollapsiblePanelExtender ID="cpeEmployeeList" runat="server">...

</cc1:CollapsiblePanelExtender>

<cc1:CollapsiblePanelExtender ID="cpeEmployeeDetail" runat="server">...

</cc1:CollapsiblePanelExtender>

<asp:Panel ID="panelTitleIntroduction" runat="server" Height="25px" Width="405px">...

</asp:Panel>

<asp:Panel ID="panelContentIntroduction" runat="server" Height="160px" Width="415px">..

</asp:Panel>

<asp:Panel ID="panelTitleEmployeeList" runat="server" Height="25px" Width="405px">..

</asp:Panel>

<asp:Panel ID="panelContentEmployeeList" runat="server" Height="310px" Width="415px">..

</asp:Panel>

<asp:Panel ID="panelTitleEmployeeDetail" runat="server" Height="25px" Width="405px">..

</asp:Panel>

<asp:Panel ID="panelContentEmployeeDetail" runat="server" Height="300px" Width="415px">.

</asp:Panel>...

</ContentTemplate>

</asp:UpdatePanel>

 

Another cool property in CollapsiblePanel - ScrollContents

If you set ScrollContents to true, you can see the scroll bar in the content panel as Figure 17

<cc1:CollapsiblePanelExtender ID="cpeIntroduction" runat="server" TargetControlID="panelContentIntroduction"

ExpandControlID="panelTitleIntroduction" CollapseControlID="panelTitleIntroduction" Collapsed="false"

ImageControlID="imgBackgroundIntroduction" ExpandedImage="App_Themes/CollapsiblePanel/images/HightLightIntroduction.png"

CollapsedImage="App_Themes/CollapsiblePanel/images/BackgroundIntroduction.png" SuppressPostBack="True" ScrollContents=true ></cc1:CollapsiblePanelExtender> 

 

Figure 17 scroll bars in content panel

Figure 17 scroll bars in content panel


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
James Wu
I came to Australian at year 1989. After I finishing my master’s degree in New South Wales University in Sydney, I started my first database designer role in Sydney Water. After working for a few years for several different companies, I had chance to work in Australia’s leading financial company AMP (www.amp.com.au). My role at AMP was an internet banking developer. My main tasks included the design of middle-tier, security, transaction processes, database and front end. Currently, I am working with Taiwan Microsoft as vendor. I have strong software development knowledge in banking/financial institution. My current certifications include MCP, MCSE(Microsoft NT 4.0), MCDBA(Microsoft SQL SERVER 2000), MCSD(Microsoft Visual Studio 6.0), MCAD(Microsoft .NET) and MCSD(Microsoft .NET).
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
CollapiblePanelDemo_AJAXV1.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Become a Sponsor
 Comments
Nice Work by Matt On March 2, 2007
This is a very nice article. Well done James. You suggested this on ASP.NET forums to my post. Thanks to you I can see a good example.
Reply | Email | Delete | Modify | 
Very good by Benoy On July 30, 2007
Good work and explains in detail...Nice work...
Reply | Email | Delete | Modify | 
diagonal line draw at design time in asp.net by naveen On January 11, 2009
Hello friend I want to draw a diagonal line at design time in asp.net. Please help me how can i draw a diagonal line. Naveen
Reply | Email | Delete | Modify | 
voice chat by naveen On January 11, 2009
Hi friends please help me how can i develop voice chat in asp.net ? naveen naveenc007@gmail.com
Reply | Email | Delete | Modify | 
Payment gateway integrate by naveen On January 11, 2009
Hi friends I want to integrate online payment gateway in asp.net. Please advice how can i get API of payment gateway and integrate with our web site ? Please help naveen naveenc007@gmail.com
Reply | Email | Delete | Modify | 
hovermenu by varun On March 20, 2009
I want code of hovermenu control.
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved