<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="MultipleViews" %>
<!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:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
<asp:MultiView ID="MultiView1"
runat="server"
ActiveViewIndex="0"
OnActiveViewChanged="MultiView1_ActiveViewChanged">
<asp:View ID="View1" runat="server">
<b>Showing View #1</b><br />
<asp:Button ID="cmdNext" runat="server" Text="Next >" CommandName="NextView" />
</asp:View>
<asp:View ID="View2" runat="server">
<b>Showing View #2</b><br />
Text content.
<asp:Button ID="cmdPrev" runat="server" Text="< Prev" CommandName="PrevView" />
<asp:Button ID="cmdNext2" runat="server" Text="Next >" CommandName="NextView" />
</asp:View>
<asp:View ID="View3" runat="server">
<b>Showing View #3</b><br />
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<asp:Button ID="Button1" runat="server" Text="< Prev" CommandName="PrevView" />
</asp:View>
</asp:MultiView>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MultipleViews : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DropDownList1.DataSource = MultiView1.Views;
DropDownList1.DataTextField = "ID";
DropDownList1.DataBind();
}
}
protected void cmdShow_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = DropDownList1.SelectedIndex;
}
protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
{
DropDownList1.SelectedIndex = MultiView1.ActiveViewIndex;
}
}
|