[RESOLVED]Managing multiple CSS based on browsers

Hi,

I am working on an asp.net application, I have an issue that my CSS is not working fine in mutliple browsers i.e., its working in internet explorer, but not working fine in google chrome browser.

so, can anyone help me out , how to manage the CSS on pageload of asp.net i.e. i want to load the css based on client browser

thanks in advance

regards

M.badruddin

Hi,

Try using conditional comments and maintain separate style files for IE and others.

http://www.quirksmode.org/css/condcom.html

<!--[if IE]>
<link href="ie.css" />
<![endif]-->
<!--[if !IE]> 
<link href="other.css" />
-->

Is there any alternate for IE Ver 10.0 , since the above article wont work for IE Vers 10.0.

Please provide the code so that i can change the CSS on page load, based on client browsers

thanks

Hi

Can you tell us what kind of problem you are getting, what kind of issue browser are showing.

Dear raju,

thanks for your support, i got the solution from below link

http://stackoverflow.com/questions/6715806/load-different-css-file-based-on-browser

protected void Page_Load(object sender, EventArgs e)
{
if (Request.Browser.Browser == "IE")
{
HtmlLink css = new HtmlLink();
css.Href = ResolveClientUrl("~/Styles/Site.css");
css.Attributes["rel"] = "stylesheet";
css.Attributes["type"] = "text/css";
css.Attributes["media"] = "all";
Page.Header.Controls.Add(css);
}
else
{
HtmlLink css = new HtmlLink();
css.Href = ResolveClientUrl("~/Styles/Site_NonIE.css");
css.Attributes["rel"] = "stylesheet";
css.Attributes["type"] = "text/css";
css.Attributes["media"] = "all";
Page.Header.Controls.Add(css);
}

i had managed different browsers upon pageload

thanks 

Leave a Reply