ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

One of the most ignored or rather not talked about control in ASP.NET 2.0 (no more code name "whidbey") is the MultiView Control.

How many times we have wanted a scenario where we need to show only certain portions of a section and show the other based on a click event and allow users to toggle between the two. The solution for this in ASP.NET 1.X versions is to either go for a Tabstrip control or have a Button, Image Button etc., and have Panels which you can show and Hide.

Neither of the two were very efficient due to the following reasons.

Tabstrip
It wasnt a 100% solution for Tabbed Pages. It was a wonderful Web Control
but still had its own limitations.

Validators cannot exist happily across tabs where submission of neither of them will happen unless all the validators are satisfied.

You have to explicitly declare the Controls in the Code Behind unlike the traditional way, where you drag and drop a control and automatically, it adds the control declaration in the codebehind.

Microsoft does not support the IE Webcontrols and therefore there is no proper documentation / support for them and nor there is any reliability of performance.

Panels
You have to explicitly show a Panel and hide the other panels. Say you have 3 panels.

Then, you need to set Panel1.Visible = true and others Panel2.visible = false & Panel3.visible = false explicitly. You have to repeat these steps everytime you want to change between the panels.


Maintaining the Code becomes too tough if more panels get added.

ASP.NET 2.0 Provies a wonderful solution by means of MultiView Control. The MultiView Control combined with the View Control can provide different UI on different scenarios as and when required.

Herebelow, is the syntax for the same

<asp:MultiView ID="MultiView1" runat="server" >
<asp:View ID="View1" runat="server">
This is one section where you can have a set of controls / contents.
</asp:View>
<asp:View ID="View2" runat="server">
This is another section where you can have a different set of controls / contents.
</asp:View>
</asp:MultiView>

Now, to show the different tabs based on different events, we just need to set the following code:-

protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
}

Thats all I need to show the different parts of the UI based on scenario. This is really useful in cases of Lengthy DataForms, collecting different information from different control types based on user's input.

The MultiView control for sure is going to change the way we have been coding heavily using Panels.

Cheers and Happy Programming !!!

posted @ Friday, December 16, 2005 11:27 AM

Print

Comments on this entry:

# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by Brian at 12/16/2005 12:08 PM
Gravatar
Don't forget the Wizard control too!

# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by Radhakrishnan at 2/21/2007 7:30 AM
Gravatar
Is it possible to use the multiview control within a Formview control?
I get errors trying to do so. Please help me out

rradhakrishnaiyer@rbi.org.in

# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by ! at 2/14/2008 10:57 PM
Gravatar










!


































# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by Vuyiswa Maseko at 1/13/2009 12:20 PM
Gravatar
Nice Article. You are right its first time i hear about the Control, and the thing that made me google it is that it looked strange to me. well you just explain what it does, and i will have to figure out what are they using it for in my Application.

Thanks nice Article and Explain and a Simple example

# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by siavash at 1/16/2009 12:35 PM
Gravatar
I want to design a control that reads from a word 2007 file and shows it in default format in word file.Also this was a multiview control.
I dont know how to begin designng this control. if you can help me,it is so helpful for me.
thank alot.

# re: ASP.NET 2.0 MultiView Control - No more TabStrip / Panel Show-Hide

Left by mario oyunları at 9/21/2009 10:47 AM
Gravatar
Also this was a multiview control.
I dont know how to begin designng this control. if you can help me,it is so helpful for me.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345