MultiView and View controls allow you to divide the content of a page
into different groups, displaying only one group at a time. Each View
control manages one group of content and all the View controls are held
together in a MultiView control.
The MultiView control is responsible for displaying one View control at a time. The View displayed is called the active view.
The syntax of MultiView control is:
<asp:MultView ID= "MultiView1" runat= "server">
OutPut-
The MultiView control is responsible for displaying one View control at a time. The View displayed is called the active view.
The syntax of MultiView control is:
<asp:MultView ID= "MultiView1" runat= "server">
</asp:MultiView>
The syntax of View control is:
<asp:View ID= "View1" runat= "server">
</asp:View>
However, the View control cannot exist on its own. It would render error if you try to use it stand-alone. It is always used with a Multiview control as:
<asp:MultView ID= "MultiView1" runat= "server"> <asp:View ID= "View1" runat= "server"> </asp:View> </asp:MultiView>
Properties
ActiveViewIndex- A zero based index that denotes the active view. If no view is active, then the index is -1.
Example-
Aspx Source 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;
}
OutPut-
Thanks this is work perfectly this code
ReplyDelete