overview: code piece of hh.weblog asp.net动态添加外部CSS文件或JS文件
香水坏坏 发表于 2007-8-16 [HH.Weblog]
C#代码
- public void AddPageHeaderLink(string virtualPath ,bool isJS)
- {
- System.Web.UI.HtmlControls.HtmlGenericControl link;
- if (!isJS)
- {
- link = new System.Web.UI.HtmlControls.HtmlGenericControl( "link" );
- link.Attributes.Add( "type", "text/css");
- link.Attributes.Add( "rel", "stylesheet");
- link.Attributes.Add( "href", virtualPath );
- }
- else
- {
- link = new System.Web.UI.HtmlControls.HtmlGenericControl( "script" );
- link.Attributes.Add( "language" , "javascript");
- link.Attributes.Add( "type", "text/javascript");
- link.Attributes.Add( "src", virtualPath );
- }
- Header.Controls.Add(link);
- }
访客评论
发表评论
- 你的姓名:
- 你的网站:
- EMAIL:
- 评论内容:
- 私人

