Hi guys, I have the following piece of code to add the right CSS file in the "head" depending on browser,
string browserName = Request.Browser.Browser;
string browserVersion = Request.Browser.Version;
Control Head = Page.Master.FindControl("stuHead");
if (Head != null)
{
if (browserName == "IE")
{
if (browserVersion == "6.0")
{
Head.Controls.Add(new LiteralControl("<link rel='stylesheet' rev='stylesheet' href='Home-IE6.css' type='text/css' media='all' />"));
}
else
{
Head.Controls.Add(new LiteralControl("<link rel='stylesheet' rev='stylesheet' href='Home-IE.css' type='text/css' media='all' />"));
}
}
else
{
Head.Controls.Add(new LiteralControl("<link rel='stylesheet' rev='stylesheet' href='Home.css' type='text/css' media='all' />"));
}
}
else
{
Response.Write("<link rel='stylesheet' rev='stylesheet' href='Home.css' type='text/css' media='all' />");
}
When I open my page in IE8, sometimes I see the Home.css, actually I should be seeing the Home-IE.css. I have ensured that the Head is not null. Not sure if anyone has experienced such a thing. Any comments appreciated.