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

请高手指点,怎么重新引用CSS文件?
是这样的,会员页面HTML和CSS分离。

为了给VIP会员的页面弄得华丽尊贵一些,所以专门给VIP会员写了CSS。

原来的代码如下:
<head runat="server">
  <title>某某某的风采_空间展示</title>
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  <link type="text/css" rel="Stylesheet" href="../css/hf.css"/>
  <link type="text/css" rel="Stylesheet" href="../css/tanceng.css"/>
</head>

现在,已经给VIP会员写了两个CSS样式文件,分别是hf2.css和tanceng2.css
请问高手大侠们,当页面加载时,查询会员是VIP会员的话,怎样调用.hf2.css和tanceng2.css,从而替换hf.css和tanceng.css

请问用什么方法实现?谢谢!



------解决方案--------------------
jquery按需加载js和css插件使用说明
------解决方案--------------------
不会帮顶
------解决方案--------------------
C# code

        protected void Page_Load(object sender, EventArgs e)
        {
            if (vip)
            {
                System.Web.UI.HtmlControls.HtmlLink hf2 = new System.Web.UI.HtmlControls.HtmlLink();
                hf2.Attributes["type"] = "text/css";
                hf2.Attributes["rel"] = "Stylesheet";
                hf2.Href = "../css/hf2.css";
                this.Header.Controls.Add(hf2);
            }
            else
            {
                System.Web.UI.HtmlControls.HtmlLink hf = new System.Web.UI.HtmlControls.HtmlLink();
                hf.Attributes["type"] = "text/css";
                hf.Attributes["rel"] = "Stylesheet";
                hf.Href = "../css/hf.css";
                this.Header.Controls.Add(hf);
                System.Web.UI.HtmlControls.HtmlLink tanceng = new System.Web.UI.HtmlControls.HtmlLink();
                tanceng.Attributes["type"] = "text/css";
                tanceng.Attributes["rel"] = "Stylesheet";
                tanceng.Href = "../css/tanceng.css";
                this.Header.Controls.Add(tanceng);
            }
        }

------解决方案--------------------
C# code
        bool vip = true;
        HtmlLink link = new HtmlLink();
        link.Attributes.Add("type", "text/css");
        link.Attributes.Add("rel", "stylesheet");
        if (vip)
            link.Attributes.Add("href", "css/vip.css");
        else
            link.Attributes.Add("href", "css/normal.css");
        Page.Header.Controls.Add(link);