在DLL中添加CSS文件(类库) [英] Add CSS File in DLL (Class Library)
本文介绍了在DLL中添加CSS文件(类库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为 AddJsFunction的类库项目,其中包含一个包含所有相关JS,CSS和图像文件的类。下面是上述类中的IncludeJsFile方法,其中我添加了所有按预期工作的Javascript文件。
I have a Class Library project named "AddJsFunction" which contains a class where I am including all related JS, CSS and Image files. Below is the IncludeJsFile method inside the above mentioned class where I am adding all the Javascript files which works as expected.
public void IncludeJsFile(Page pg)
{
pg.ClientScript.RegisterClientScriptInclude(this.GetType(), "Test2", pg.ClientScript.GetWebResourceUrl(this.GetType(), "AddJsFunction.queue.js"));
string csslink2 = "<script type='text/javascript' language='javascript' src='" + pg.ClientScript.GetWebResourceUrl(this.GetType(), "AddJsFunction.queue.js") + "' />";
LiteralControl include2 = new LiteralControl(csslink2);
pg.Header.Controls.Add(include2);
}
相同的方式,我想嵌入我尝试包含的CSS文件,如下所示
Same way I want to embed the CSS files which i tried to include like shown above but that is not working and I need some help to do the same.
谢谢,
VY。
Thanks, VY.
推荐答案
来自是还有一个CSS的ClientScriptManager.RegisterClientScriptInclude等效项:
HtmlLink link = new HtmlLink();
link.Href = "Cases/EditStyles.css";
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
//check if it exsists on the page header control first
foreach (Control control in pg.Header.Controls)
{
if ((control is HtmlLink) &&
(control as HtmlLink).Href == href)
{
return true;
}
}
pg.Header.Controls.Add(link);
这篇关于在DLL中添加CSS文件(类库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文