从后面的代码中添加一个外部css文件。

时间:2022-11-22 23:02:10

I've a CSS file, say SomeStyle.css. Is it possible for me to apply this style sheet document to an aspx page from its code behind?

我有一个CSS文件。我是否可以将这个样式表文档应用到aspx页面上,从它后面的代码?

1 个解决方案

#1


36  

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") + "\" />"));

#1


36  

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") + "\" />"));