Click here to Skip to main content
Click here to Skip to main content

How to use Multiview Control in ASP.NET

, 23 Jul 2007
Rate this:
Please Sign up or sign in to vote.
The article describes how to use the Multiview server control in asp.net
Screenshot - MVC.jpg

Introduction

This article describes how to use the multiview server control in asp.net with c# as the backend

Background

The multiview control is a new feature of asp.net 2.0 which was introduced with visualstudio 2005.The main advantage of the multiview control is tnat we can specify the required view only(Ie display the required view only) on a single page.Multiview control helps us to create different views in the same page and display the view as the user clicks the links. With Multiview control the tab functionality is achived in asp.net.

Using the code

ASPX Code

<table border="0" cellpadding="2" cellspacing="3" width="100%">

<tr>
<td>
<asp:LinkButton ID="lnkTab1" runat="server" OnClick="lnkTab1_Click">Tab1</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab2" runat="server" OnClick="lnkTab2_Click">Tab2</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab3" runat="server" OnClick="lnkTab3_Click">Tab3</asp:LinkButton></td>
</tr>
<tr>
<td colspan="3">
<asp:MultiView ID="MultiView1" runat="server">
<table width="100%" cellpadding="2" cellspacing="5">
<tr>
<td>
<asp:View ID="View1" runat="server">
Content 1 goes here</asp:View>
</td>
<td>
<asp:View ID="View2" runat="server">
Content 2 goes here</asp:View>
</td>
<td>
<asp:View ID="View3" runat="server">
content 3 goes here</asp:View>
</td>
</tr>
</table>
</asp:MultiView></td>
</tr>
</table>

C# code

protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
   {
   SetDefaultView();
   }

}

private void SetDefaultView()
{
MultiView1.ActiveViewIndex = 0; 
}

protected void lnkTab1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0; 
}
protected void lnkTab2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1; 
}
protected void lnkTab3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}

 

Points of Interest

This is a cool new feature of ASP.NET 2.0,Try this.

History

Created by George Zacharia on 23/07/2007 .

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

George Zacharia
Web Developer
India India
No Biography provided

Comments and Discussions

 
GeneralMy vote of 1 PinmemberReonekot10-Feb-14 22:50 
SuggestionMulti view pointer PinmemberKanzz_25413-Jun-13 2:56 
GeneralMy vote of 5 PinmemberMember 94272117-Jun-13 3:42 
GeneralNice Explain PinmemberSinghAnuj5-Apr-13 19:53 
QuestionMy Vote +5 PinmemberHarshit Raj Singh15-Sep-12 8:01 
GeneralMy vote of 5 PinmemberPrasad_Kulkarni14-Jun-12 0:31 
GeneralMy vote of 1 Pinmemberycano19-Jan-12 10:11 
Question???? PinmemberRavindra_Parcha14-Jan-12 8:05 
Questionsub Pinmembervinothharshad28-Jun-11 20:47 
GeneralMy vote of 1 PinmemberMilton_win18-Jun-09 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 24 Jul 2007
Article Copyright 2007 by George Zacharia
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid