Pages

Friday 15 February 2013

if IE Conditional CSS using ASP.NET Themes

 string appPath = Request.ApplicationPath;
        if (appPath.Length == 0)
            appPath = "/";
        else if (!appPath.EndsWith("/"))
            appPath += "/";

        String themeDir = Page.Theme;
        if (themeDir == null || themeDir.Length == 0)
            themeDir = Page.StyleSheetTheme;
        String conditionalCode = 
@"<!--[if IE 6]><link rel='stylesheet' href='" + 
  appPath + @"app_themes/" + themeDir + 
  @"/style.css.ie6' type='text/css' /><![endif]-->
  <!--[if IE 7]><link rel='stylesheet' href='" + 
  appPath + @"app_themes/" + themeDir + 
  @"/style.css.ie7' type='text/css' /><![endif]-->
";
        Page.ClientScript.RegisterClientScriptBlock
            ("".GetType(), 
            "iespecific", 
            conditionalCode);

No comments:

Post a Comment