CSS files are all added with media=print after a few postbacks


The code in the global.asax.cs that adds the media="print" attribute to the <link /> tags that reference stylesheets ending in "print.css" that ASP.NET adds via theming starts to add the attribute to all <link /> tags after a few postbacks. This appears to be a bug in ASP.NET causing this. To fix you need to explicitly remove the media attribute in an else clause:
var printLinks = page.Header.Controls
            .Where(l => l.Href.EndsWith("print.css", StringComparison.InvariantCultureIgnoreCase));
        foreach (var link in page.Header.Controls.OfType<HtmlLink>())
            if (printLinks.Contains(link))
                link.Attributes["media"] = "print";
Closed Jan 31, 2009 at 10:09 AM by damianedwards


wrote Jan 31, 2009 at 10:09 AM

Resolved with changeset 10449.

wrote Feb 13, 2013 at 6:51 PM

wrote May 15, 2013 at 3:52 AM