Active index : MultiView « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
            <asp:View ID="View1" runat="server">
                Enter your name:<br />
                First Name&nbsp;<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                <br />
                Last Name
                <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnView1Next" runat="server" Text="Next" /></asp:View><asp:View ID="View2" runat="server">
                Birthday:<br />
                <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
                <br />
                <asp:Button ID="btnView2Previous" runat="server" Text="Previous" />
                <asp:Button ID="btnView2Next" runat="server" Text="Next" /></asp:View><asp:View ID="View3" runat="server">
                Thank you for registering with us.<br />
                <br />
                <asp:Button ID="btnView3Finish" runat="server" Text="Finish" />
                <asp:Button ID="btnView3Reset" runat="server" Text="Reset" /></asp:View></asp:MultiView>
        </div>
    </form>
</body>
</html>

File: Default.aspx.vb


Partial Class Default_aspx
    Inherits System.Web.UI.Page
    Protected Sub btnAllButtons_Click(ByVal sender As Object, _
                                      ByVal e As System.EventArgs) _
                                      Handles btnView1Next.Click, _
                                      btnView2Next.Click, btnView2Previous.Click, _
                                      btnView3Finish.Click, btnView3Reset.Click
        Select Case CType(sender, Button).Text
            Case "Next"
                MultiView1.ActiveViewIndex += 1
            Case "Previous"
                MultiView1.ActiveViewIndex -= 1
            Case "Finish"
                Response.Write("You have registered as " & _
                                txtFirstName.Text & _
                                txtLastName.Text & "<br/>")
                Response.Write("Birthday " & _
                                Calendar1.SelectedDate)
                btnView3Finish.Enabled = False
                btnView3Reset.Enabled = False
            Case "Reset"
                MultiView1.ActiveViewIndex = 0
        End Select
    End Sub
End Class








3.23.MultiView
3.23.1.MultiView hides and display different areas of a page, useful to create a tabbed page
3.23.2.What is an asp:MultiView (C#)
3.23.3.Displaying a Multi-Part Form
3.23.4.Use the MultiView control to dynamically switch views in a page
3.23.5.MultiView and View Controls
3.23.6.Active index