Multiview in asp.net
Here by this article we learn how to use Multiview and View in asp.net
Multiview is very usefull you can use it instead of content pages for master pages.
First
Write this code in asp.net first page
Default.aspx:
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <form id=”Form” runat=”server”> <div id=”header”> <asp:Label ID=”Label1? runat=”server” Font-Bold=”True” Font-Size=”Medium” Font-Underline=”True” Text=”View and MultiView Controls Example”></asp:Label> OnClick=”Button1_Click” BackColor=”Black” ForeColor=”#00CCFF” /> <asp:Button id=”Button2? runat=”server” Text=”Click Me to See View2? OnClick=”Button2_Click” BackColor=”Black” ForeColor=”#00CCFF” /> <asp:Button id=”Button3? runat=”server” Text=”Click Me to See View3? OnClick=”Button3_Click” BackColor=”Black” ForeColor=”#00CCFF” /> <br /><br /> <asp:MultiView id=”MultiView1? runat=”server” ActiveViewIndex=0> <asp:Image ID=”Image3? runat=”server”ImageUrl=”Loading1.gif” /> <br /> <br /> |
Declaration:
Here we are creating three buttons for three views(under MultiView Control)
All buttons are changing the view and evrey view is having another contents
Here you have to paste three images in your solution explorer I have used here
1- dwaynejohnson.jpg
2- My pic.jpg
3- Loading1.gif
We have created One MultiView control and three View controls under Multiview control.
Note: You can use many View controls under MultiView controls as per your requirements.
Under view controls we are using image controls
You can use anycontrol which you want in place of image control.
Second:
Now add this code
Default.aspx.cs:
using System; { |
Declaration:
Here on the page loading the Multiview is invisible
When you click the first button it will show the first view control
When you click the second button it will show the second view control
When you click the third button it will show the third view control
SetActiveView is using for set the active view.
Interface:

Conclusion:
Here we learn how to use MultiView control in asp.net which works like a master page and its content pages.
If you feel help then contact me I will be happy to help you …
Thanks
Nikhil Kumar

Join the conversation! Your thoughts help the community grow.