views:

34

answers:

1

As I understand it you can tell the IE8 (and I assume later versions) how to best render your page.

This is useful because the page may have been designed for IE7, quirks mode or to target IE8 standards mode. As I have it, the default behaviour for IE8 when it encounters a page is to render in IE8 standards mode (not sure how it interprets the DOCTYPE though). With this default the user could change the rendering mode by clicking on the "Compatibility View" button next to the refresh button.

This is nice to give the user some control, but bad when you know your site only renders well with IE7 or whatever. In that case you don't want to enable the user to make the wrong choice and that's where the ability for a website to tell the >= IE8 browser how to render the page is very useful.

You simply have to provide the X-UA-Compatible meta tag the within the head tag. There are loads of references on the web how to do this and what values can be used. Remember to make it the first one.

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
  <head  id="Head1" runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />

OK, so it's nothing new so far - however it just doesn't work for my ASP.NET project? I've tried it on a couple of other projects I have and the same problem.

Is there perhaps a scenario where because I'm using developer tools like Visual Studio, etc. that IE has been configured to always show the "Compatibility View" button for debugging purposes? Grasping at straws here I know.

A: 

I found out why this is happening.

It seems that ASP.NET's theming is interfering. When looking at the rendred output there is a dynamically inserted tag for the stylesheet (one for each) from the theme.

The ASP.NET theming engine inserts these items above the X-UA-Compatible meta tag, thus breaking IE's expectation of having it as the first tag in the head element.

So an ASP.NET site that has theming and the following in the source:

<html xmlns="http://www.w3.org/1999/xhtml"&gt; 
  <head  id="Head1" runat="server"> 
    <meta http-equiv="X-UA-Compatible" content="IE=7" />

will get rendered out as follows:

<html xmlns="http://www.w3.org/1999/xhtml"&gt; 
  <head id="ctl00_Head1"> 
    <link href="App_Themes/White/Default.css" type="text/css" rel="stylesheet" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />

This seems to be a bit of a bug. I'll create a MS Connect issue for it.

Jaans
Here's the MS Connect issue link: https://connect.microsoft.com/VisualStudio/feedback/details/581278Vote for it if you agree.
Jaans