惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
C
Cisco Blogs
The Hacker News
The Hacker News
T
Threatpost
S
Schneier on Security
K
Kaspersky official blog
Spread Privacy
Spread Privacy
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
量子位
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
Security Latest
Security Latest
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News and Events Feed by Topic
爱范儿
爱范儿
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
V
V2EX
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
Simon Willison's Weblog
Simon Willison's Weblog
L
LangChain Blog
W
WeLiveSecurity
Cloudbric
Cloudbric

博客园 - refuly

【半原创】将js和css文件装入localStorage加速程序执行 SqlAgent备份脚本 ASP.net 使用HttpHandler实现图片防盗链 提取HTML代码中文字的C#函数 - refuly - 博客园 水晶头的制作 解决ASP.NET“类型初始值设定项引发异常” 解决vs2005 经WebDeployment发布后 global.asax 事件不启动 C# 实现Epson热敏打印机打印 Pos机用 去掉文件名中的非法字符 - refuly - 博客园 window.onbeforeunload与window.onunlad对比 用Response.Filter生成静态页[要注意并发问题] asp.net Excel导入&导出 - refuly - 博客园 计算机端口的介绍 Sql Server数据导出EXCEL 获取字符串的真实长度 c# 小数位数处理 新旧身份证合法性验证及验证算法 C#进制转换 Asp.net 备份、还原Ms SQLServer及压缩Access数据库
HttpModule通过修改CSS切换皮肤
refuly · 2009-05-29 · via 博客园 - refuly

换皮肤的方式有很多种,最简单的通常就是切换页面CSS,而CSS通常写在外部CSS文件里。那么切换css其实就是更换html里的link href路径。我在网上搜索了下。一般有两种方式:

1,在页面放一个holder控件。然后用编程方式把当前用户的风格css link写入页面。
2,通过反射机制,逐个控件设置css样式。
上面两种方式都挺麻烦的,
第一种需要在每个页面上放一个holder控件。类似的做法还有把link标签加runat=server的做法。页面多了,都比较麻烦。
第二种不用考虑了。性能编程效率上问题多多。

记得以前在学习DNN的时候,在他里面发现了一种修改form里默认的action地址的方式,直接参考下。还不错:
直接重写Render事件
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            StringWriter sw = new StringWriter() ;
            HtmlTextWriter htmlWriter = new HtmlTextWriter(sw) ;

            base.Render(htmlWriter) ;
            //当前用户选择的风格css
            string css = "<link href=\"css url\" rel=\"stylesheet\" type=\"text/css\">" ;

            string html = sw.ToString() ;
            int startPoint = html.IndexOf("</head>", StringComparison.CurrentCultureIgnoreCase);
            if (startPoint > 0)
            {
                html = html.Insert(startPoint, css);
            }

            writer.Write(html) ;
        }
把这个放在每个页面的基类PageBase里。那就方便多了。
当然,如果不想在让每个page都继承自定义的基类的方式,那也可以通过在HttpModule里写。也很方便.
一处写好,页页受用呀。