C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




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


Posted Date: 19 Dec 2005    Resource Type: Articles    Category: Web Applications
Author: Harish RanganathanMember Level: Gold    
Rating: Points: 10



Introduction


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.

Common Requirement


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 MultiView Control


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.

Summary


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




Responses

Author: selva venkatesh    26 Dec 2005Member Level: Gold   Points : 0
hi your article is very useful for find the solution of asp.net 2.0 view pageing. Continue to post the asp 2.0 information articles

ok bye,
selva


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: A better way of working with IE Webcontrols - Part II
Previous Resource: Html Tab Control !!!
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use