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

Description

 
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
.OfType<HtmlLink>()
.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";
}
else
{
link.Attributes.Remove("media");
}
}

File Attachments


No files are attached


Closed Jan 31 at 11:09 AM  by damianedwards

Comments

most recent at top (show oldest at top)
wrote Jan 31 at 11:09 AM
Resolved with changeset 10449.

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2009.10.27.15987