<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultiViewTab.aspx.cs" Inherits="MultiViewTab" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> <style> .MenuCell { border-color: Black; border-width: 1px; border-style:solid; background-color: WhiteSmoke; color: Black; text-align: center; height:25px; font-size: x-small; } .MenuCellSelected { border-top-color:Black; border-left-color:Black; border-right-color:Black; border-bottom-color:Gainsboro; border-width:1px; background-color:Gainsboro; font-weight:bold; font-size: x-small; } .MenuCellHover { background-color: LightSteelBlue; font-size: x-small; } .Canvas { background-color: Gainsboro; font-size: x-small; border-left: 1px solid black; border-bottom: 1px solid black; border-right: 1px solid black; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:Menu ID="Menu1" Width="300px" runat="server" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False" OnMenuItemClick="Menu1_MenuItemClick"> <StaticMenuItemStyle CssClass="MenuCell" ItemSpacing="0px" /> <StaticHoverStyle CssClass="MenuCellHover" /> <StaticSelectedStyle CssClass="MenuCellSelected" ItemSpacing="0px" /> </asp:Menu> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> <asp:View ID="View1" runat="server"> <table width="600px" height="400px" cellpadding="0" cellspacing="0"> <tr> <td class="Canvas"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td> </tr> </table> </asp:View> <asp:View ID="View2" runat="server"> <table width="600px" height="400px" cellpadding="0" cellspacing="0"> <tr> <td class="Canvas"> <asp:Button ID="Button2" runat="server" Text="Button" /> </td> </tr> </table> </asp:View> <asp:View ID="View3" runat="server"> <table width="600px" height="400px" cellpadding="0" cellspacing="0"> <tr> <td class="Canvas"> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> </td> </tr> </table> </asp:View> </asp:MultiView></div> </form> </body> </html>
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 MultiViewTab : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { for (int index = 0; index < MultiView1.Views.Count; index++) { Menu1.Items.Add(new MenuItem(MultiView1.Views[index].ID, index.ToString())); } Menu1.Items[0].Selected = true; } } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value); } }


No comments:
Post a Comment