The other day, my wife explained that she has been telling her team to use IE6, since IE7 breaks her ASP.NET application. She has been keeping this a secret from me, since obviously it is a grave violation of trust between mates. She came to me only because IT is forcing upgrade of IE7 on her team, and she needed help.
It took me only a few moments to find the problem. ASP.NET is pretending to issue XHTML and claims to adhere to strict doctype. At the top of the .aspx page was an XHTML doctype (click the image to see it; curses on WordPresses buggy “security filter”):
I deleted it, and now the site renders the same in IE7 as in IE6.
~
This simple trick should fix your problem. If you’re interested in hearing why, please read on.
The short explanation is this: IE7 is far more standards-conformant than IE6, so pages that rely on conformance bugs in IE6 look bad on IE7. ASP.NET pretends to be standards-conformant, but that really just means “IE6 bug-compatible”. If you tell ASP.NET to stop pretending, then IE7 says “Oh, this page isn’t really standards-conformant — I’ll render it bug-compatible with older versions of IE”.
So, why does ASP.NET even bother adding that DOCTYPE if it is deceptive? Well, there are two reasons, neither very satisfying. The first is that the XHTML political lobby insisted that “XHTML gooood, HTML baaaad”. So everyone was arm-twisted into emitting XHTML. The problem is, when the political lobbying started, none of the web browsers actually supported XHTML, they just pretended. So a server like ASP.NET could choose between emitting code that was XHTML, or emitting code that looked as much like XHTML as possible without breaking Netscape and IE. Code that looks like XHTML without breaking the browsers is a tiny subset of “actual XHTML”.
Farcial as it may be, it was the best anyone could do, and it got the complainers to stop kvetching. Now we can all live under the illusion that we support XHTML, even if trivial little changes and isomorphic infosets would break half the world.
The problem is, as soon as you claim to be XHTML, the modern browsers assume that you are also using real CSS. This goes for Firefox as well as IE. But IE6 didn’t support CSS properly; so now the GUI web designer tool had two choices:
- Emit good CSS, so the code that looks good in Opera but not IE6, and maybe looks good in Firefox
- Pretend to be good CSS (by the DOCTYPE), but emit code that looks good on IE6 and hope it works in Firefox or Opera
It’s clear which choice was made.
Enter IE7. The newest version of IE, like the newest versions of Firefox and Opera, does a much better job of rendering standards-conformant pages. Suddenly, writing code that looks good only in IE6 seems like a bad idea. And even if that wasn’t such a bad idea, pretending that it’s standards-conformant sure seems silly. It just makes our hard work to adopt standards in IE7 look bad.
Well, that’s the story. Knowing this, you have two choices:
- Use the legacy design tool and tell ASP.NET to stop pretending that it’s emitting real standards-conformant code.
- Use more modern design tools (like Expression) and let ASP.NET rightly claim that the code is standards-conformant.