参考地址:http://www.cnblogs.com/MICRONET/archive/2006/05/23/406974.html 代码如下: # using System; # using System.Data; # using System.Configuration; # 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; # # /// <summary> # /// CSSService 服务类 # /// </summary> # public class CSSService # { # public CSSService() # { # // # // TODO: 在此处添加构造函数逻辑 # // # } # # #region 切换CSS # # /// <summary> # /// 切换CSS # /// 作者:胡海 # /// 日期:2008-12-17 # /// </summary> # /// <param name="page">当前页面的Page</param> # /// <param name="CSSFilePath">CSS文件相对网站根目录地址</param> # public static void SwitchCSS(Page page, string CSSFilePath) # { # HtmlLink link = new HtmlLink(); # link.Href = CSSFilePath; # link.Attributes[ "rel" ] = "stylesheet" ; # link.Attributes[ "type" ] = "text/css" ; # page.Header.Controls.Add(link); # } # #endregion # } 调用代码: CSSService.SwitchCSS(Page, Common.CSSFilePath); 注意:CSS中使用类来控制元素的表现形式,否则CSS不会起效。