日期:2014-05-20 浏览次数:20976 次
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="CTWebPlatform.SiteMaster" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> <asp:ContentPlaceHolder ID="HeadContent" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form runat="server"> <div class="page"> <div class="header"> <div class="title"> <h1> 数据管理平台 </h1> </div> <div class="loginDisplay"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <br /> </div> <div class="clear hideSkiplink"> <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" Orientation ="Horizontal" IncludeStyleBlock="false" onmenuitemclick="NavigationMenu_MenuItemClick" ViewStateMode="Enabled" ClientIDMode="AutoID" EnableTheming="False" EnableViewState="False" RenderingMode="List" > </asp:Menu> </div> </div> <div class="main"> <asp:ContentPlaceHolder ID="MainContent" runat="server"/> </div> <div class="clear"> </div> </div> <div class="footer"> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CTWebPlatform.localhost; using System.Data.SqlClient; using System.Data; using System.Configuration; using System.Web.UI.HtmlControls; using System.Collections; namespace CTWebPlatform { public partial class SiteMaster : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { NavigationMenu.Orientation = Orientation.Horizontal; if (((CTUser)Session["Login"]) == null) { //Response.Redirect("~/SysManager/Login.aspx"); // LinkButton1.Text = "登陆"; Label1.Text = ""; } else { CreateMenu(); // LinkButton1.Text = "退出"; string strUser = "操作员“" + ((CTUser)Session["Login"]).strUserName + "”已登陆"; Label1.Text = strUser; } } protected void NavigationMenu_MenuItemClick(object sender, MenuEventArgs e) { } protected void CreateMenu() { if ((CTUser)Session["Login"] != null) { CTWebPlatform.localhost.CTWebInterface mWebInt = new CTWebInterface(); IList MenuList = mWebInt.GetMenulistByUser((CTUser)Session["Login"]); int nPItem = MenuList.Count; for (int nIndex = 0; nIndex < nPItem; nIndex++) { if (((CTSysMenuFun)(MenuList[nIndex])).subMenuList != null ) { MenuItem item = new MenuItem(); item.Text = ((CTSysMenuFun)(MenuList[nIndex])).strDisplayName; if ( ((CTSysMenuFun)(MenuList[nIndex])).subMenuList != null ) { int nSubCount = ((CTSysMenuFun)(MenuList[nIndex])).subMenuList.Count(); for (int nSubIndex = 0; nSubIndex < nSubCount; nSubIndex++) { MenuItem itemsub = new MenuItem(); itemsub.Text = ((CTSysMenuFun)(MenuList[nIndex])).subMenuList[nSubIndex].strDisplayName; itemsub.NavigateUrl = ((CTSysMenuFun)(MenuList[nIndex])).subMenuList[nSubIndex].strMenuURL; item.ChildItems.Add(itemsub); } } NavigationMenu.Items.Add(item); }else if (((CTSysMenuFun)(MenuList[nIndex])).strDisplayName.Trim() == "首 页" || ((CTSysMenuFun)(MenuList[nIndex])).strDisplayName.Trim() == "帮 助" ) { MenuItem item = new MenuItem(); item.Text = ((CTSysMenuFun)(MenuList[nIndex])).strDisplayName; item.NavigateUrl = ((CTSysMenuFun)(MenuList[nIndex])).strMenuURL; NavigationMenu.Items.Add(item); } } if ( nPItem == 0) { //Response.Redirect("~/SysManager/HelpForm.aspx"); } } } protected void LinkButton1_Click1(object sender, EventArgs e) { //if (LinkButton1.Text == "登陆") //{ // Response.Redirect("~/SysManager/Login.aspx"); //} //if (LinkButton1.Text == "退出") //{ // Response.Redirect("~/SysManager/Login.aspx"); //} } } }