MultiView and View Controls in ASP.NET 2.0
page 2 of 4
by Jason N. Gaylord
Feedback
Average Rating: 
Views (Total / Last 10 Days): 147246/ 1550

Section 1: Using Panels in ASP.NET 1.x
Here is an example of how controls and content were hidden or shown with ASP.NET 1.x:

<%@ Page Language="VB" %>

<script runat="server">

    Sub Button1_Click(s as Object, e as EventArgs)
        Panel1.visible = true
        Panel2.visible = false
        Panel3.visible = false
    End Sub

    Sub Button2_Click(s as Object, e as EventArgs)
        Panel1.visible = false
        Panel2.visible = true
        Panel3.visible = false
    End Sub

    Sub Button3_Click(s as Object, e as EventArgs)
        Panel1.visible = false
        Panel2.visible = false
        Panel3.visible = true
    End Sub

</script>

<html>

<head>
<title>Panels in ASP.NET 1.x</title>
</head>

<body>

<form runat="server">
    <asp:Button id="Button1" runat="server" Text="Panel one" OnClick="Button1_Click" /> &nbsp;
    <asp:Button id="Button2" runat="server" Text="Panel two" OnClick="Button2_Click" /> &nbsp; 
    <asp:Button id="Button3" runat="server" Text="Panel three" OnClick="Button3_Click" />
    <br /><br />

    <asp:Panel id="Panel1" runat="server">
        Content Here (Panel 1)…
    </asp:Panel>

    <asp:Panel id="Panel2" runat="server" visible="false">
        Content Here (Panel 2)…
    </asp:Panel>

    <asp:Panel id="Panel3" runat="server" visible="false">
        Content Here (Panel 3)…
    </asp:Panel>
</form>

</body>

</html>

View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 7 and 4 and type the answer here:

User Comments

Title: MultiView and View Controls in ASP.NET 2.0   
Name: Asath
Date: 11/14/2008 4:42:06 AM
Comment:
This is good article. Thks
Title: MultiView and View Controls in ASP.NET 2.0   
Name: Pandithuraithevar
Date: 9/26/2008 1:55:38 AM
Comment:
Thanks for this article, It is really help us..
Title: MultiView and View Controls in ASP.NET 2.0   
Name: DeveloperZero
Date: 9/9/2008 9:30:06 PM
Comment:
Perfeeeeeeeeeeeeeect.
Thanks, thanks, thanks from Mexico d.f.
Title: Multi View   
Name: Rakesh jaiswal
Date: 9/7/2008 6:00:24 AM
Comment:
good
thanks for posting this. This is very helpful.
Title: feedback form   
Name: omprakash
Date: 8/23/2008 2:19:07 AM
Comment:
I want to make feedback form like that of u which control will be helpful and how to use that because i want the feedbacks should follow the the previous feedbacks.
Title: Multiview control and Drop down list control   
Name: Dhavithra
Date: 8/19/2008 9:55:15 AM
Comment:
This one is a nice article.
I already used multiview control with menu items instead of the tab control.
Now i have to link the views of multiview control with the items in DropDownList.
Can you please help me?
Title: MultiView and View controls   
Name: Hemant Kumar
Date: 7/28/2008 7:22:21 AM
Comment:
Thank for this article, It is really help us.
Title: MultiView and View controls   
Name: Santosh Kumar
Date: 7/9/2008 5:49:02 AM
Comment:
Thank for this article, this is nice article.
View is container of comman control and multiview is container of several view control.and view control contain all controls.

Santosh Kumar
http://www.operativesystems.com
Title: MultiView and View Controls in ASP.NET 2.0   
Name: sebastian
Date: 6/19/2008 8:09:11 AM
Comment:
nice
Title: Multiview with out using codes   
Name: HoseA
Date: 6/15/2008 9:33:45 PM
Comment:
Thanks for the lesson.

I know there is a way to use the mulit view with out using codes. I just cant get it to work? GRRRRRRR

It has to do with the button properties
the commandName property and the commandArgument

I just can get the dang thing working

Anybody can help Mr.GreenHorn..

thanks
HoseA
Title: Views in Multiview   
Name: Hundie
Date: 5/22/2008 9:17:20 PM
Comment:
I have created about three views in multiview server control. What I came accross as an issue is that when I activate the visiblity of the last view it is displayed in a place where I put on the page and is not displayed near the top page of the page and hence I am happy if there is some one who have such experience and solutions before.
Thanks,
Title: I want detail information   
Name: Pravin
Date: 5/15/2008 5:30:59 AM
Comment:
it is good but i want im detail
Title: Response to Nobody important   
Name: Steven Bey
Date: 5/13/2008 9:45:24 AM
Comment:
The only difference between a full postback and partial postback (actually called a partial page update) is that the render phase only concerns itself with the updated controls. This means that the page still goes through its full life cycle, which includes loading the entire control hierarchy.
Title: Nice Simple Article   
Name: ollyb303
Date: 4/16/2008 11:38:42 AM
Comment:
Thanks Jason, you've made this very very easy
Title: programmer   
Name: sukhman
Date: 3/6/2008 12:40:28 PM
Comment:
i would put the needed buttons inside the view it self.
Title: Response to Steven Bey (1/4/2008 8:01:17 AM)   
Name: Nobody important
Date: 2/28/2008 3:20:48 PM
Comment:
Quote: "...it is extremely inefficient to load all of the controls on the page for every request."

Use partial postbacks with AJAX and you will not have this problem. The page will load once and then only the content that needs to be updated is updated on postback. Of course, you will have to set it up to work properly.
Title: made simple   
Name: KyD
Date: 2/28/2008 11:24:02 AM
Comment:
Great... you made this really simple to understand. Thanks
Title: really a Good artical we want some more   
Name: gajendra
Date: 2/2/2008 6:08:51 AM
Comment:
really helpful..gud work.
keep it up...
Title: Good artical   
Name: Sanjeev Gupta
Date: 2/1/2008 5:56:09 AM
Comment:
I am very happy to view this code
Title: Response to Barry (9/4/2007 6:29:37 PM)   
Name: Steven Bey
Date: 1/4/2008 8:01:17 AM
Comment:
I understand that the advantage of loading each view, along with all of its child controls, is that it maintains viewstate between postback, however, it is extremely inefficient to load all of the controls on the page for every request. Consider 4 Views with 20 child controls. In this scenario each request would be processing 60 controls (i.e. going through each control's lifecycle) for absolutely no reason. That is the reason I said it was poor design, which I still stand by.
Title: it's very helpful for real time   
Name: yogeswar reddy
Date: 12/20/2007 12:49:49 AM
Comment:
hai

thanks for all this type code and details is very helpful
realtime
Title: that's really helpful   
Name: yogesh
Date: 11/27/2007 12:43:02 AM
Comment:
hi,
thanks for posting this. This is very helpful.
Title: Good   
Name: JaiminShah
Date: 11/13/2007 7:07:27 AM
Comment:
Jabeer (if it's not too late),so..,
This is a good article. It's not brain surgery, and appropriately, it isn't loaded with a lot of fluff. A great reference.
Title: ViewState in hidden Views   
Name: Michael Freidgeim
Date: 10/29/2007 12:52:19 AM
Comment:
Bilal Haidar [MVP] told in the feedback above that " multiple views doesn't mean loading all views and then hiding/showing others".
But from http://www.beansoftware.com/ASP.NET-Tutorials/MultiView-Control.aspx "States of all Views are stored in ViewState.".
Who is correct?
Title: very gud   
Name: pilaka rasi
Date: 10/15/2007 9:02:11 AM
Comment:
the article has covered only coding part..but it would have been gud if theory part was also given ..
Title: Very Good One   
Name: Sameer
Date: 9/13/2007 2:24:20 AM
Comment:
This is good article
Title: Response to Client-Side and Non-Postback questions   
Name: Barry
Date: 9/4/2007 6:33:14 PM
Comment:
While this isn't a client-side control, there are many out there that provide this capability. In fact, Telerik (www.telerik.com) has a tab control that will work both client-side and server side.

Also, you might want to jump into Ajax. Having the tab fire a server-side function while not having to refresh the entire page (only the contents of the multiview) is the way to go.
Title: Good/Concise Article   
Name: Barry
Date: 9/4/2007 6:30:58 PM
Comment:
This is a good article. It's not brain surgery, and appropriately, it isn't loaded with a lot of fluff. A great reference.
Title: Response to Steven Bey   
Name: Barry
Date: 9/4/2007 6:29:37 PM
Comment:
Actually, while you're right that all of the views and their child controls are loaded for every single page request, your assertion that this is bad design is not correct. By making sure that all of the controls are loaded, you're able to have the viewstate and control values persist between postbacks.
Title: good   
Name: suresh
Date: 8/31/2007 5:02:17 AM
Comment:
its a easy to use a control.
Title: Number of Views Loaded   
Name: Steven Bey
Date: 7/24/2007 6:11:23 AM
Comment:
Chad's answer to Jabeer's question is incorrect. All of the Views and, therefore, all their child controls are loaded for every single page request. This is extremely bad. Poor design by Microsoft I'm afraid!
Title: RP   
Name: RP
Date: 6/26/2007 2:40:17 AM
Comment:
All these controls are server side. Can we have client side controls?
Title: To Jabeer   
Name: Chad
Date: 5/26/2007 11:17:20 PM
Comment:
Jabeer (if it's not too late),

The Multiview only loads the controls in the view you being called.
Title: asp.net   
Name: ramu
Date: 5/22/2007 10:50:08 AM
Comment:
How the Webapplication Compiles ?
What is Loggin?
How to working IIS Server
Title: Jabeer   
Name: jabeerbe@gmail.com
Date: 5/10/2007 9:44:33 AM
Comment:
Hi Jason,
Can you clarify my doubt. I have the Multiview with 8 views. I have so many controls in each and every View.
My Questio is when the page load. Did all the control load at a time or based upon the View we are selecting.

Regards,
A Jabeer Ali
Title: Ti malakia article   
Name: dikasths
Date: 5/7/2007 7:05:02 AM
Comment:
Deikse kana screenshot tou paradeigmatos sou re paparaaaaaa
Title: Is iT possible Multiview With out firing PostbackEvent   
Name: SoftPro
Date: 5/4/2007 7:12:43 AM
Comment:
When I will click on View of a MultiView That time postback Event should not fire..means I want view in Javascript coding
Title: another page in multiview   
Name: Umer
Date: 5/2/2007 8:11:59 AM
Comment:
Is it possible to attach a View to a predefined page. Lets say I have a page called "Default.aspx" which contains a View and I have another page called "About.aspx". I want the contents of "About.aspx" to show up in the View in "Default.aspx".
Umer
Title: NICE.. GUD JOB   
Name: LV
Date: 4/24/2007 2:31:16 PM
Comment:
Gud one Nce to see this type of article.which helps in improving coding standards.
Title: Thanks   
Name: Neeraj soni
Date: 3/5/2007 7:04:19 AM
Comment:
I am very happy to getting the code of multiview
Title: thanks   
Name: Mina
Date: 1/27/2007 2:59:31 PM
Comment:
thanks it is good article
Title: very cool   
Name: Abdulla Hussein
Date: 11/23/2006 9:47:05 AM
Comment:
Mutliview is nice control I like it, it reduce the codebehind , very nice
Title: HTML Output   
Name: gangadhar
Date: 10/26/2006 3:24:41 AM
Comment:
hi ,
is there any way so that all the views of multiview control will be in the client side itself as in tabcontrol ,so that there will be no post back to the server
Title: Functionality with Multiviews?   
Name: Eduab
Date: 9/28/2006 6:26:14 AM
Comment:
I'm running into this problem or maybe it's supposed to work that way. When adding a gridview with sorting pagin etc.. into say 2 views in same aspx, the first view works fine full functionality; but the second is only a display when clicked to sort it goes back to first view, which makes it useless as a panel it's just like a screenshot.
Title: Thanks   
Name: Malcolm
Date: 9/11/2006 11:41:10 AM
Comment:
Thanks for taking the time to post this :) Good luck, M
Title: panel   
Name: okragesh@yahoo.co.in
Date: 8/26/2006 11:48:36 PM
Comment:
i drag one pael in asp.net form aftwer running it is not visible
i am new person in asp.net
please help me to view the panel in asp.net form
Title: thanks   
Name: ne
Date: 8/22/2006 10:54:54 AM
Comment:
Thanks! it is very good and helpful
Title: skeet   
Name: Skeet master
Date: 8/3/2006 1:22:04 PM
Comment:
thanks that rocks
Title: Re: WIM   
Name: Jason N. Gaylord
Date: 5/10/2006 1:22:06 PM
Comment:
It should still work that way Wim. I'd suggest posting your code to the ASP.NET forums at www.asp.net.
Title: Controls in a multiView   
Name: Wim
Date: 5/10/2006 10:09:47 AM
Comment:
I have a GridView in a View, that View is part of a MultiView. How can I set the DataSource of the GridView?
Without the view it would be myGridView.DataSource = myDataSet. But it won't work that way. :-(
(I use ASP.NET 2.0, VS 2005, CodeBehind VB)
Can someone help me please?
Title: RE: Attach an aspx page to a View   
Name: Jason N. Gaylord
Date: 4/12/2006 3:26:29 PM
Comment:
Do you mean a User Control? :)
Title: Attach an aspx page to a View   
Name: Dsyfa
Date: 4/12/2006 9:43:20 AM
Comment:
Is it possible to attach a View to a predefined page. Lets say I have a page called "Default.aspx" which contains a View and I have another page called "About.aspx". I want the contents of "About.aspx" to show up in the View in "Default.aspx".

Kapeesh?
Title: old news   
Name: JC
Date: 4/4/2006 3:20:05 AM
Comment:
This control is available in v1
Title: Drop Down Method   
Name: Easton Harvey
Date: 3/29/2006 5:55:58 PM
Comment:
Use the following method for a dropdown box

MultiView1.SetActiveView((View)MultiView1.FindControl(ddPicker.SelectedValue));
Title: muliview   
Name: Ashley
Date: 2/27/2006 6:06:37 AM
Comment:
whether all browsers will support this muliview?
Title: Mr   
Name: benyair
Date: 1/27/2006 2:05:48 PM
Comment:
great article simple and easy to use

thank you
Title: Rendering   
Name: Dave
Date: 11/30/2005 7:08:27 AM
Comment:
The multiview doesn't render any html so there are no issues with browsers
Title: Re   
Name: Uday
Date: 11/29/2005 1:58:10 AM
Comment:
the same functionality can be achieved by using the Wizard control as per i done.
I wnt to know the difference between Wizard & Multiview Controls.
Plz do the necessary.
Title: Firefox rendering   
Name: Tony
Date: 11/21/2005 8:29:32 AM
Comment:
If you're concerned about the different results that were being returned in Firefox you may want to look into customising the browsercaps section of your machine.config file of web.config file. The following url has a sample you can use: http://slingfive.com/pages/code/browserCaps/
Title: ViewState   
Name: Bilal Haidar [MVP]
Date: 10/6/2005 8:52:13 AM
Comment:
Hello again,
Well it seems I was wrong, the ViewState is loaded for all the views, isn't this bad? I thought each view will be loaded seperately, why wasn't done like so?

Regards
Title: Engineer   
Name: Bilal Haidar [MVP]
Date: 10/6/2005 8:34:42 AM
Comment:
Hello Jason:
I have been working for a while with ASP.NET 2.0, but today by accident I read something about MultiView, so I thought of checking aspalliance for such an article.
The great thing is that, no ViewState load is added to the page at all, I mean, if you have for example a detailsview and gridview, each in a seperate view, then loading one of them doesn't load the other, so multiple views doesn't mean loading all views and then hiding/showing others, which is a great thing to do and use on a website, less ViewState and more flexibility.

Regards
Title: Re:   
Name: Jason
Date: 7/14/2005 3:03:20 PM
Comment:
Download what? The MultiView and View controls? They are part of ASP.NET 2.0. You can download the beta software at http://msdn.microsoft.com.
Title: great !   
Name: Miles
Date: 7/12/2005 5:38:49 AM
Comment:
but where can i download it ?

Thanks.
Title: RE: HTML Output   
Name: Jason
Date: 6/20/2005 9:32:05 AM
Comment:
They are Div's in IE. I'm not sure what they are in FireFox. I'll have to check and let you know.
Title: HTML Output   
Name: David
Date: 6/20/2005 6:12:47 AM
Comment:
What HTML is outputted with MultiView, the problem with panels was they rendered div tags in IE and tables in FireFox

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 12/4/2008 3:18:33 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search