Thursday, August 30, 2007

CSS with a ~

One issue of trying to use "~" in your CSS, is the fact that you cannot use [if IE 6] with it.
The problem becomes that the "<!--" becomes a comment.
So below is the .NET fix for this.

<%
string browser = Page.Request.Browser.Browser;
string version = Page.Request.Browser.Version;
version = string.Format("{0}.{1}", version.Split('.'));
decimal verInt = Convert.ToDecimal(version);
if ((browser == "IE") && (verInt < 7.0m)) lnkSSIE6.Visible = true;
if ((browser == "IE") && (verInt >= 7.0m)) lnkSSIE7.Visible = true;
%>
<!--if IE 6.X-->
<link id="lnkSSIE6" rel="stylesheet" type="text/css" href="~/css/css_ie6/ct_styles_ie6.css"
runat="server" visible="false" />
<!--if IE 7.X-->
<link id="lnkSSIE7" rel="stylesheet" type="text/css" href="~/css/css_ie7/ct_styles_ie7.css"
runat="server" visible="false" />