日期:2014-05-18  浏览次数:20437 次

如何在后台控制所有页面背景色????急!!!!!!!!!!!!!!!!
如题

------解决方案--------------------
如果你只要修改颜色,那么就按照我1楼那样做就可以了,稍微做下修改,每个页面都加上
<body bgcolor="<%=strColor%>">,
定义一个基类PageBase.cs,所有页面继承这个类,在这个类里设置
public string strColor;
pagebase.cs
/// <summary>
/// the base class for Page。
/// </summary>
C# code
public class PageBase : System.Web.UI.Page
{
    #region 变量声明
    public string strColor;
    #endregion

    #region 本类构造函数
    public PageBase()
    {
           strColor="#cc00ff";
    }
    #endregion
}

------解决方案--------------------
自已写个类
C# code

    public static System.Drawing.Color TheColor
    {
        get
        {
            if (System.Web.HttpContext.Current.Session["TheColor"] != null)
            {
                return (System.Drawing.Color)System.Web.HttpContext.Current.Session["TheColor"];
            }
            else
            {
                return new System.Drawing.Color();
            }
        }
        set
        {
            System.Web.HttpContext.Current.Session["TheColor"] = value;
        }
    }

------解决方案--------------------
探讨
9楼的  yfqvip
我的颜色值不要  strColor="#cc00ff"; 这样去固定啊。要可变的呀 如我在后台管理时,选了其它值  但这样做的话一刷新就变了