Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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).
Posted
Comments
StianSandberg 19-Jul-12 6:11am    
you are using webforms? Let me know if you are using MVC. Then I'll tell you a great MVC4 solution :)
sai sagar 19-Jul-12 6:28am    
web forms
StianSandberg 19-Jul-12 6:39am    
ok, then Sandeep Mewara's answer is a perfect solution for you :)

1 solution

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.
C#
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);


You can also add it using Javascript, details here: Adding Javascript and CSS files at run time[^]
 
Share this answer
 
Comments
sai sagar 19-Jul-12 6:25am    
that code is not working
StianSandberg 19-Jul-12 6:40am    
do you get any error message or exception? Make sure the css.Href is correct..
sai sagar 19-Jul-12 7:00am    
no exceptions but same is same as my first css style shett, it cant changes to 2nd sheet
sai sagar 19-Jul-12 8:09am    
it's working.. thanks
Sandeep Mewara 19-Jul-12 8:13am    
Welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900