Blue Theme Orange Theme Green Theme Red Theme
 
Discover the top 5 tips for understanding .NET Interop
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
Search :       Advanced Search »
Home » WebForms Controls » Mimic the Appearance of Outlook's Sidebar with the Multi-view Control

Mimic the Appearance of Outlook's Sidebar with the Multi-view Control

This article describes a simple way to mimic the appearance of Microsoft’s Outlook sidebar within an ASP.NET 2.0 web application. The approach is based upon the use of the existing Multi-View control contained in the standard ASP.NET 2.0 toolbox and does not require much time or effort to implement. This article includes a sample web application that presents an example of the approach in use.

Author Rank :
Page Views : 11270
Downloads : 259
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
OutlookLikeSite.zip
 
 
Nevron Chart
Become a Sponsor
Nevron Chart
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Introduction:

This article describes a simple way to mimic the appearance of Microsoft's Outlook sidebar within an ASP.NET 2.0 web application.  The approach is based upon the use of the existing Multi-View control contained in the standard ASP.NET 2.0 toolbox and does not require much time or effort to implement.

This article includes a sample web application that presents an example of the approach in use.

Getting Started:

In order to begin, unzip the downloaded files and open the project provided.  Within the project you will find a simple ASP.NET 2.0 application written in C#.NET; the web application contains a single web page (Default.aspx).

The default.aspx page is built from a template table containing a sidebar, a header, and a main display area.  In order to add a similar table to a project, create a new web page, open the "Layout" menu option, then select "Insert Table" from that option.  The insert table dialog will then appear (Figure 1).  From this dialog, select the "Template" option at the top of the dialog, then open the combo box to reveal the table options.  Select the option showing "Header and Side".  When you click "Ok" a table in format specified will be added to the open web page.  You may wish to set the size properties for each of the table's areas before adding any additional controls; it is typically easier to set up the proportions of the table when no controls are yet placed within its bounds.  One thing you might want to do at this point is to set the sidebar area's vertical alignment property to bottom.  You can set the banner and main display area as you set fit.

Once the table is placed and you are happy with its arrangement, it is time to add the controls necessary to support the appearance of Microsoft Outlook.


 
Figure 1:  Insert Table Dialog in Visual Studio 2005

Take a look at Outlook (figure 2) and note that the sidebar is really pretty simple.  There are a set buttons at the bottom of the sidebar and, above the buttons, is a display area used to display the controls relevant to the button selected.  Whenever a new button is clicked from the bottom of the sidebar, the contents of the sidebar's display area are updated to show the selection's control options.

At the top of the sidebar is a label that displays the contents of the sidebar.  Whenever a new option is selected by clicking one of the buttons at the bottom of the sidebar, the label is updated to reflect the selection.

Inside the sidebar's display area, there can be additional collapsible panels that may be expanded or contracted to reveal or hide the panel's content.  These are very simple to construct from the Microsoft multi-view panel as well and a simple example of such a panel is included in the demonstration.

Figure 2: Microsoft Outlook with Sidebar Visible (on left)

Once the table has been configured, drag a label from the toolbox and place it in the sidebar area of the table, next, drag a multi-view control under the label, and then drag three view controls inside of the multi-view control.  Lastly, drag three button controls into bottom of the sidebar area.

You may drag some other controls inside each of the view panels; I merely placed some checkbox and radio button lists into the views for the purposes of this demonstration however the view control is container control and you may place any other controls inside a view control that you wish.

To demonstrate the collapsible panel, I constructed a simple user control that you will find in the demonstration project.  The user control is entitled, "CollapsePanel.cs"; if you open it up for a look, you will see that it contains a single panel with its width set to 100%, inside the panel you will find a small table with three rows, the second row contains two table cells, in the left hand cell is a label, and in the right hand cell, there are two image button controls.  The left button control is named, "btnOpen" and the right hand button control is named "btnClose".  Each image button is assigned an arrow looking icon, one pointing down and one pointing to the right.  The visibility of the "btnClose" image button is set to false.

I placed a single label control in rows 1 and 3 and set the text property to "<hr/>" to draw a horizontal line above and below the title.  Below the table there is a single multi-view control and inside the multi-view control is a single view control.  When a page loads this control, the view control will default to show no panels at all, if you prefer to have the control load with the panel visible, you will need to set the active view index property of the multi-view control to "0"  or "View1" (our single panel) and swap the visibility between the two image button controls.

The "btnClose" click event handler will set the multi-view control's active index property to "-1" to hide the view control.  The event handler will also swap the visibility of the "btnClose" button to false and the "btnOpen" button's visibility to true.  The entire user control's code behind page is as follows:

public partial class CollapsePanel : System.Web.UI.UserControl

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void btnClose_Click(object sender, System.Web.UI.ImageClickEventArgs e)

    {

        MultiView1.ActiveViewIndex = -1;

        btnOpen.Visible = true;

        btnClose.Visible = false;

    }

    protected void btnOpen_Click(object sender, System.Web.UI.ImageClickEventArgs e)

    {

        MultiView1.ActiveViewIndex = 0;

        btnOpen.Visible = false;

        btnClose.Visible = true;

    }

 

}

 

Once this  user control has been built, add it to one of the views in the default.aspx page.

The code for the main page is just about as simple as it is for the user control.  Here again the objective is merely to swap visible panels in response to button click events originating from the three buttons beneath the multi-view control.   Given it would be nice to open up one of the panels on page load, the page load event contains a little bit of code to handle that task.  In this case, page load looks like this:

protected void Page_Load(object sender, EventArgs e)

{

    if (!(Page.IsPostBack))

    {

        this.MultiView1.SetActiveView(View1);

    }

}

 

Here, if the page is not a post back, the multi-view control is configured to display view 1 of the three available views.  You can set this value with a integer if you prefer.  If you don't want any of the panels to display on the initial page load, set the value to "-1" or do nothing as by default the multi-view control will hide all of the views.

The only task remaining is to set the event handlers for the three button controls used to select each of the three separate views contained in the multi-view control, that is accomplished with the following bit of code:

protected void Button1_Click(object sender, System.EventArgs e)

{

    this.MultiView1.SetActiveView(View1);

    Button1.Font.Bold = true;

    Button2.Font.Bold = false;

    Button3.Font.Bold = false;

    txtHeader.Text = "Days";

}

protected void Button2_Click(object sender, System.EventArgs e)

{

    this.MultiView1.SetActiveView(View2);

    Button1.Font.Bold = false;

    Button2.Font.Bold = true;

    Button3.Font.Bold = false;

    txtHeader.Text = "Tools";

}

protected void Button3_Click(object sender, System.EventArgs e)

{

    this.MultiView1.SetActiveView(View3);

    Button1.Font.Bold = false;

    Button2.Font.Bold = false;

    Button3.Font.Bold = true;

    txtHeader.Text = "Cars";

}

 

This is also pretty simple, in each event handler the multi-view controls set active view is passed the view to be displayed; the multi-view control is only capable of displaying a single view control at a time so you need not write any additional code to hide the other views as you would have to do if you were to implement a similar project with a panel control.

After setting the current view, the selected button's text is bolded and the unselected buttons have the bolding removed, and lastly, the text box containing the sidebar's header text is updated to reflect the current selection.

That wraps it up, if you build and run the web application, you should see the following in your browser: (figure 3)

Figure 3:  Demonstration Web Application

If you click on each of the buttons you should see the content of the sidebar update.  If you select the "Cars" button, you should see the collapsible panel user control and if you click on its icon, you should see it reveal and hide the contents of its multi-view control:  (Figures 4 and 5)

Figure 4:  Collapsible Panel Closed

Figure 5:  Collapsible Panel Opened

NOTE: THIS ARTICLE IS CONVERTED FROM  VB.NET To C# USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (http://www.vbdotnetheaven.com/).

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Scott Lysle
Freelance software developer residing in Alabama. Bachelors, Masters Degrees from Wichita State University. I spent the first half of my career working on aircraft controls and displays and in that time I worked on the cockpits for the OH-58 AHIP, the AH-1W, the V-22, the F-22, the C-130J, the C-5 AMP, AWACS, JPATS, and a few others. Since 1997 I have been largely involved with Windows and web development, GIS application development, consumer electronics development (embedded linux/java), but still sometimes work on aircraft and military projects, the most recent of which was the presidential transport helicopter. I tend to work primarily with C/C++, Java, VB, and C#.
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.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Chart
Become a Sponsor
 Comments
DevExpress Free UI Controls
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.