SIGN UP MEMBER LOGIN:    
ARTICLE

ASP.NET 2.0 MultiView Control

Posted by Mahesh Chand Articles | ASP.NET Programming October 09, 2005
A View control is a container of multiple controls and a MultiView control works as a container of groups of View controls. In this article, I will discuss how to work with View and Multiview controls.
Reader Level:
Download Files:
 

The MultiView and View controls are new addition to ASP.NET 2.0. If you have ever created a Tab Control in ASP.NET, you will find MultiView and View control very familiar.

A View control works as a container of common controls and a MutliView control works as a container of several View controls. In this step by step tutorial, I will show you how to create a MultiView control and generate different views depending on the selection.

First of all, I create three links and drop one MultiView control on the page. My page looks like Figure 1. So idea here is if I click on My Websites link, I should see a list of web sites. When I click on My Schedule, I should see a calendar control, and when I click on Upload Photo link, I should see something where I can upload a photo. As you can see, this is very similar to a Tab Control and Tab Pages.

Figure 1. MiltiView

Now I drop three View controls on MultiView control as you can see in Figure 2.

Figure 2. MultiView with three Views

Now next thing I want to do is design my Views. As you can see from Figure 3, I put a BulletedList with hyper links on it. On second view, I put a Calendar control and on third View, I drop a File UpLoad control.  

Figure 3. Multiview with three Views and controls

MultiView's ActiveViewIndex property decides which view is active. So now I am going to add my hyperlinks click event handlers. As you see in the following code, I simply set the ActiveViewIndex property to 0, 1, and 2 respectively, which represents first, second, and third Views respectively.

protected void MyWebSitesLink_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}

protected void MyScheduleLink_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}

protected void UploadPhotoLink_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}

The View control has a TabIndex (remember I said View works as a Tab Page ;-) ), which sets the TabInxex of a View. The TabIndex is mapped with the ActiveViewIndex of MultiView control.

Now I simply run my sample and click on My Websites, My Schedule, and Upload Photo links and it loads different views.

Figure 4. MultiView in Action

 

Login to add your contents and source code to this article
Article Extensions
Contents added by Jonacani Waisu on May 12, 2009
Download File: frmAddEmployee.zip
The master forms are on top of the multiview tabs, I want to insert the master forms first then insert the multiview form pages with the same ID that use in the master forms, I want the code to smae in one table.
share this article :
post comment
 

Good article that got me started on using this control.

Posted by Jude Wood Jun 06, 2011

Hello!

Why your example not contains designer-files?

Posted by Andrej Oct 09, 2009

dude..say u have radio button in any one of the views.If u want to use the selected value of that radio button in any other view.Basic thing is that the control belongs to the same page..so u can just use the value of thar radio button in any of those views.just use

radiobutton1.selectedindes.value in other view.

Posted by shekar penugonda Mar 24, 2009

I would like to show my views the depends on my radio button list selection , let say i have a list with "yes" and " no" if i select yes i would like to populate view 1 and if i clicked on no i would like to populate view 2.

Posted by joe smith Mar 15, 2008

Hi, Nice article Can u help me with this problem i hv four views , 3 contains datagrid with POSITION - Not Defined , 1 contains txtbox with value from database POSITION-ABSOLUTE , the views with controls POSITION - Not Defined appear normally in the screen (like in tabs) , but the view with control POSITION-ABSOLUTE remains as in design mode ( not in the tab) thanks in advance

Posted by uma booshanam Dec 04, 2007
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • 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.
    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.
Become a Sponsor