ASP.NET Tutorial/ASP.net Controls/View

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Using the MultiView and View server controls (C#)

<%@ Page Language="C#"%>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            MultiView1.ActiveViewIndex = 0;
        }
    }
    void NextView(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex += 1;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>MultiView Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:MultiView ID="MultiView1" Runat="server">
            <asp:View ID="View1" Runat="Server">
                A<p />
                <i>asdf</i><p />
                <asp:Button ID="Button1" Runat="Server" Text="Next Step" 
                 OnClick="NextView" />
            </asp:View>
            <asp:View ID="View2" Runat="Server">
                B<p />
                <i>sdfg.</i><p />
                <asp:Button ID="Button2" Runat="Server" Text="Next Step" 
                 OnClick="NextView" />
            </asp:View>
            <asp:View ID="View3" Runat="Server">
                C<p />
                <i>dfgh<br />
                </i><p />
            </asp:View>
        </asp:MultiView>     
    </form>
</body>
</html>


Using the MultiView and View server controls (VB)

<%@ Page Language="VB"%>
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not Page.IsPostBack Then
            MultiView1.ActiveViewIndex = 0
        End If
    End Sub
    
    Sub NextView(ByVal sender As Object, ByVal e As System.EventArgs)
        MultiView1.ActiveViewIndex += 1
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>MultiView Server Control</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:MultiView ID="MultiView1" Runat="server">
            <asp:View ID="View1" Runat="Server">
                A<p />
                <i>asdf</i><p />
                <asp:Button ID="Button1" Runat="Server" Text="Next Step" 
                 OnClick="NextView" />
            </asp:View>
            <asp:View ID="View2" Runat="Server">
                B<p />
                <i>sdfg.</i><p />
                <asp:Button ID="Button2" Runat="Server" Text="Next Step" 
                 OnClick="NextView" />
            </asp:View>
            <asp:View ID="View3" Runat="Server">
                C<p />
                <i>dfgh<br />
                </i><p />
            </asp:View>
        </asp:MultiView> 
    </form>
</body>
</html>