Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

ASP.

Net MultiView Control


Multi View Cont rol i s an asp. net web se rver co nt rol. Mul tiview Cont rol is a same as T ab con trol . If you want make a complex de sign ing on o ne web forms then you have to use mu ltiv iew cont rol.

Mlti View con trol is a co ntaine r of seve ral view con tro l. In a m ultiv iew cont rol t here a re many view con tro l for des ign ing sepa rat ion of view for u ser.

The View co nt rol is a conta iner of several web se rver cont rol s. Usin g the mu ltiv iew cont rol we can feel the mul tip le page view desi gn on a s ingle web pa ge.

We can also say mult iview con tro l allow use r to create d ifferen t view on si ngle web page. T here a re many view con tro l in a mu ltiview c ont rol, eac h view cont rol ha s some web se rver cont rol fo r desi gn web page. we can see sin gle view at a tim e on web page by spec ify the ActiveViewInd ex p rope rty of mul tiview con tro l.

All view co ntrol ass ign au tomati cally i ndex to all it, the i ndex always sta rt f rom zero. The fi rst view1 index is zero, secon d is o ne and so on….
If we want to dis play fi rst view on web pa ge, then we need to wri te MultiView1.ActiveViewIndex=0.

Here we take an example to unde rsta nd how to u se mult iview con tro l in as p.net c#.

First c reate a asp.net web applica tion and desig n web forms li ke below.
Design the web form wi th a mu ltiview co nt rol and three view c ont rol wit hin i t along wi th th ree bu tton cont rol.

The HTML Design code for multiview is:


<body>
<form id="form1" runat="server">
<div>
MultiView Control in ASP.Net
<table align="center" class="style1" style="border: thin solid #008080">
<tr>
<td style="text-align: center">
<asp:Button ID="btnview1" runat="server" onclick="btnview1_Click" Text="AWP” />
<asp:Button ID="btnview2" runat="server" onclick="btnview2_Click" Text="Java" />
<asp:Button ID="btnview3" runat="server" onclick="btnview3_Click" Text="Linux" />
</td>
</tr>
<tr>
<td>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<table border="1" >
<tr>
<td class="style5" style="text-align: center">
View -1</td>
</tr>
<tr>
<td >
AWP Notes</td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
<table border="1" >
<tr>
<td style="text-align: center">
View -2</td>
</tr>
<tr>
<td class="style6">
Java Notes</td>
</tr>
</table>
</asp:View>
<asp:View ID="View3" runat="server">
<table border="1" class="style3">
<tr>
<td style="text-align: center">
View -3</td>
</tr>
<tr>
<td >
Linux Notes</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>

</div>
</form>
</body>

.cs code:
protected void btnview1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnview2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void btnview3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}

You might also like