2

I'm hoping to force IE9 into IE8 compatibility mode on just two pages in my site. I'm using the Kentico CMS though, so I don't have an ASPX page that I can go and modify the HEAD tag of. So I was hoping to add the META tag by using a user control or a web part.

In the web part, I tried the following code:

this.Page.Header.Controls.Add(new LiteralControl(mystring));

However, this typically adds the header as the last tag in the HEAD section. IE compatibility mode requires that this be the first tag in the head section.

Is this possible from the code behind?

Or if someone has specialized knowledge of Kentico, a Kentico specific solution would work too.

I only want this to work on two specific pages in my site though. Not all of them!

Doozer Blake
  • 7,677
  • 2
  • 29
  • 40
Hoppe
  • 6,508
  • 17
  • 60
  • 114

2 Answers2

8

You should add an X-UA-Compatible header to Response.Headers directly rather than using an http-equiv meta.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • will I be able to force this to be the first header doing it this way? I didn't realize I could also use this.Page.Header.Controls.AddAt(0, new LiteralControl(mystring)); I looked through all of the methods and was inspecting insert, not addat. – Hoppe Oct 13 '11 at 16:54
  • @Joe: It doesn't matter this way. The order of HTTP headers doesn't matter at all. It only needs to be first if you're using a `` tag. – SLaks Oct 16 '11 at 00:03
0

You can use the Head HTML web part and place it on the documents (actually on Design tab to given page template) with the code you need and it will be added to the head tag of those pages.

If the documents are sharing a page template with documents where you do not want to apply this header code, you can use the visibility field and add a macro to return true/false. Below is an example:

{%cmscontext.currentdocument.documentname|(equals)%}

you can also use other properties than document name like document alias, ID, etc.

JurajO
  • 1