The MultiView control is a container control that can have only View Controls. The View Controls, which are also container controls, can only be housed in MultiView controls.
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="view1" runat="server"></asp:View>
</asp:MultiView>
Here three LinkButton is used to show all these three view .When you click LinkButton one then view1 will show and so on.
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Personal Information</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Contact info</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">Image</asp:LinkButton>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="view1" runat="server">
Name
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Id
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
Country
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</asp:View>
<asp:View ID="view2" runat="server">
Mob.No.
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
Email Id
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</asp:View>
<asp:View ID="view3" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/grass2.jpg" Width="121px" />
<asp:Image ID="Image2" runat="server" Height="88px" ImageUrl="~/2609grass.jpg" Width="134px" />
</asp:View>
</asp:MultiView>
protected void LinkButton1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}
The View control has a Tab Index which sets the TabInxex of a View. The TabIndex is mapped with the ActiveViewIndex of MultiView control. When you set MultiView1.ActiveViewIndex = 0; then first view will be active.
When you click LinkButton1 then Personal Information View will show in the page
When you click LinkButton2 then contact Information View will show in the page
When you click LinkButton3 then Image View will show in the page.
Leave Comment