如何在asp.net中调用css文件 [英] how to call css files in asp.net

查看:392
本文介绍了如何在asp.net中调用css文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用resx文件概念在asp.net中为多语言应用程序创建了2个CSS文件.我的语言是英语和阿拉伯语.

如何根据我的选择(英语或阿拉伯语)调用css文件.

i created 2 css files for multi languages application in asp.net using resx files concept. my languages are English and Arabic.

how to call css files based on my selection(english or arabic).

推荐答案

在运行时通过代码关联css文件.根据选择的需求/语言,添加CSS文件.
这意味着,您需要在运行时提供CSS文件的源.
Associate css file at runtime through your code. Based on the need/language selected, add the CSS file.
This means, you need to provide the source of CSS file at runtime.
HtmlLink css = new HtmlLink();
css.Href = "css/myCurrentLanuageStylesheet.css"; // Put your file path defined by logic here!
css.Attributes["rel"] = "stylesheet";
css.Attributes["type"] = "text/css";
css.Attributes["media"] = "all";
Page.Header.Controls.Add(css);



您也可以使用Javascript添加它,详情请参见:



You can also add it using Javascript, details here: Adding Javascript and CSS files at run time[^]


这篇关于如何在asp.net中调用css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆