ASP.NET实例代码教程:动态切换CSS样式
文章作者:网友投稿 发布时间:2008-12-18 16:04:17 来源:网络
烈火建站网(LieHuo.Net)asp.net文档 下面是实例代码,站长朋友们可以自己动手试一下:注意:CSS中使用类来控制元素的表现形式,否则CSS不会起效。
烈火建站学院(LieHuo.Net)asp.net文档 下面是实例代码,站长朋友们可以自己动手试一下:
- 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;
- public class CSSService
- {
- public CSSService()
- {
-
-
-
- }
- #region 切换CSS
-
-
-
-
-
-
-
- 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不会起效。