简体   繁体   English

从后面的代码添加外部css文件

[英]To add an external css file from the code behind

I've a CSS file, say SomeStyle.css. 我有一个CSS文件,比如SomeStyle.css。 Is it possible for me to apply this style sheet document to an aspx page from its code behind? 我可以将此样式表文档从其代码后面应用到aspx页面吗?

You can add literal controls to your header control: 您可以向标题控件添加文字控件:

Page.Header.Controls.Add(
    new System.Web.UI.LiteralControl("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResolveUrl("~/Styles/SomeStyle.css") + "\" />"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM