Ticket Q482587
Visible to All Users

Set IE Compatibility Mode to IE8 - Document Mode - SharePoint 2010

created 12 years ago

DevExpress
(v. 12.2.4.0) for SharePoint 2010 applications.
We need to
set document mode in IE: IE8 standards - Sharepoint don't like IE9 document mode.

This work,
but set highest possible document mode, it
is not good for us.

C#
HttpContext.Current.Items ["__DXPageRequiresIE8CompatibilityMode"] = new Object(); DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(); DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(this.Page);

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns:o="urn:schemas-microsoft-com:office:office"
__expr-val-dir="ltr" lang="pl-pl" dir="ltr">
<head><meta
http-equiv="X-UA-Compatible" content="IE=edge" />
http://www.devexpress.com/DXR.axd?r=1_6,1_7,1_8,1_5,1_1,1_3,1_4,1_2-NE8q6<meta
http-equiv="X-UA-Compatible" content="IE=8" /><meta
name="GENERATOR" content="Microsoft SharePoint"
/><meta name="progid"
content="SharePoint.WebPartPage.Document" /><meta
http-equiv="Content-Type" content="text/html;
charset=utf-8" /><meta http-equiv="Expires"
content="0" /><title>…
Meta tag is first, it’s working.
Second meta tag (“IE=8”) is from master page, IE
ignore this tag.

But code:

C#
HttpContext.Current.Items ["__DXPageRequiresIE8CompatibilityMode"] = new Object(); DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8); DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8, this.Page.Master);

Do nothing!HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns:o="urn:schemas-microsoft-com:office:office"
__expr-val-dir="ltr" lang="pl-pl" dir="ltr">
<head>http://www.devexpress.com/DXR.axd?r=1_6,1_7,1_8,1_5,1_1,1_3,1_4,1_2-NE8q6<meta
http-equiv="X-UA-Compatible" content="IE=8" /><meta
name="GENERATOR" content="Microsoft SharePoint"
/><meta name="progid"
content="SharePoint.WebPartPage.Document" /><meta
http-equiv="Content-Type" content="text/html; charset=utf-8"
/><meta http-equiv="Expires" content="0"
/><title>
First tag
is (link rel="stylesheet”), second
is “X-UA-Compatible” – unfortunately IE9 ignore this tag
and set Document mode to IE7 - it destroy SP page layout.
Question:
How to set Document mode to IE8?
How to
insert meta tag “X-UA-Compatible” before “stylesheet”?

Show previous comments (2)
DevExpress Support Team 12 years ago

    Grzegorz,
    Thank you for your clarification. I am afraid I do not have an immediate answer. We need some time to check and discuss this behavior with our team. We will update this thread as soon as we have any results.

      Hello Grzegorz,
      We need to clarify some extra information that may help us provide you with an appropriate solution:
      >>It is not hard-coded, You can edit this, but this is not the point.
      Do you mean that you have administrative access to the SharePoint pages and the corresponding master pages? I.e., you are not just creating portable/WebPart solutions for 3-rd SharePoint-based portals;
      >>This work, but set highest possible document mode, it is not good for us.
      Would you please clarify the following:
      - "where" (in context of each page/module/code file) you are executing this code?
      - how you are inserting out controls to the SharePoint environment (directly to pages, though WebParts/VisualWebParts)?

      GK GK
      Grzegorz Kolasinski 1 12 years ago

        Hello,
        We have administrative access to SharePoint farm, so yes, we are able to edit the masterpage. We are creating our web parts programmatically.
        We are using ASPxGridViewGrid control in our custom control inside our custom web part.
        In control .ascx file we have:
        <dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" Width="100%" GridLines="None" > …</dx:ASPxGridView>
        In a WebPart (System.Web.UI.WebControls.WebParts) class we have a following method:
             protected override void OnInit(EventArgs e)
                  {
                       base.OnInit(e);
                       //This works but sets he highest IE document mode:
                       //HttpContext.Current.Items["__DXPageRequiresIE8CompatibilityMode"] = new Object();
                       //DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge();
                       //DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(this.Page);

        //This doesn’t work – sets IE7 document mode instead of IE8
                       HttpContext.Current.Items["__DXPageRequiresIE8CompatibilityMode"] = new Object();
                       DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8);
                       DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8, this.Page);
                  }

        Answers approved by DevExpress Support

        created 12 years ago (modified 12 years ago)

        Hello Grzegorz,
        Modify your current implementation in the following manner to achieve your goal:
        >>We have administrative access to SharePoint farm, so yes, we are able to edit the masterpage.

        1. Remove the "meta" from the mentioned master page;
          >>This work, but set highest possible document mode, it is not good for us.
        2. Use the ASPxWebControl.SetIECompatibilityMode method (instead of the ASPxWebControl.SetIECompatibilityModeEdge one) and pass the:
          - "8" value as a first parameter;
          - the modified earlier master page as a second parameter. Use the Page.Master property recursively to achieve the root master page:
        C#
        //DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(); DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8, Page.Master ...);

        In this case, the required "meta" tag is inserted at the first position in the "head" tag (i.e., before the DevExpress resource links).

          Show previous comments (1)

            Hello,
            Thank you for informing me of your results. This information is very helpful.
            >>I guess that method "DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8, Page.Master);"
            has a bug, and DO NOTHING
            I believe that this method works as it should. You can check it with the E4366 - How to adjust DevExpress ASP.NET controls when opening a page in the Internet Explorer Compatibility Mode Code Central example. It is an illustration for the KA18646 - How to adjust DevExpress ASP.NET controls when opening a page in the Internet Explorer Compatibility Mode KB Article.
            It seems that here some specific of the SharePoint master page structure takes place. I need to clarify extra information in order to provide you with an appropriate solution.
            >>1) We removed „meta” tag from master page
            I think you are talking about the "v4.master" master page. If not, please clarify the required one.
            >>2) protected override void OnInit(EventArgs e)
            2) Check the "Page.Master" property recursively until it is equal to "null". Specify the last available master page (file name). Is it a master page mentioned above?
            >>Multiple WebParts on page (1 webPart x5 instances on page)
            Make a detailed screencast that illustrates the page state before and after adding a WebPart with DevExpress controls (keep Dev Toolbar/F12 visible):
            - Before checking the points mentioned below, specify the current IE browser Compatibility Settings. Make a screenshot of the "Tools -> Compatibility View Settings" window;
            - Run any problematic WebPart under the Visual Studio Debug Mode;
            - Open a page with the WebPartZone without DevExpress ASP.NET controls;
            - Insert the WebPart to the page. Examine the Page.Master property recursively;
            - Illustrate how the page is changed and values of Browser/Document modes.
            I only want to make sure that I am examining this issue under the same conditions, so that a solution can be applied in your real applications. Your time and effort are greatly appreciated.

            GK GK
            Grzegorz Kolasinski 1 12 years ago

              Mike, Please do the following steps
              1)     Create Visual Web Part (Visual Studio 2010)
              2)     Add DevExpress Grid (ASPxGridView)
              3)     In .cs file add:
              protected override void OnInit(EventArgs e)
              {
              base.OnInit(e);
              //working
              DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(this.Page);
              }
              4)     Add Web Part on SharePoint page
              5)     Open IE9 and check HTML source
              should be: <head><meta http-equiv="X-UA-Compatible" content="IE=edge" />
              Now try this:

              1. In .cs file add:
                protected override void OnInit(EventArgs e)
                {
                base.OnInit(e);
                //not working
                //DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityMode(8, this.Page);
                }
              2. Open IE9 and check HTML source
                There is no <head><meta http-equiv="X-UA-Compatible" content="IE=8" />
                Instead is <head> < link rel="stylesheet" type="text/css" href="/DXR.axd?r=1_6,1_7,1_8,1_5,1_1,1_3,1_4,1_2-NE8q6" / >

                Hello Grzegorz,
                Thank you for providing additional information.
                >>//working
                >>DevExpress.Web.ASPxClasses.ASPxWebControl.SetIECompatibilityModeEdge(this.Page);
                Since the meta tag is correctly injected, I believe both the SetIECompatibilityMode and SetIECompatibilityModeEdge work as they should.
                Since the SetIECompatibilityMode method does not inject the meta tag, I assume that your IE browser already has the pre-defined Compatibility Mode enabled. That's why our code decided that the "compatibility behavior" is turned on and there is no need to inject the meta tag.
                To provide you with a more precise answer, I still need the details that I requested earlier:
                - Before checking the points mentioned below, specify the current IE browser Compatibility Settings. Make a screenshot of the "Tools -> Compatibility View Settings" window.
                >>That behavior causes our sharepoint pages to render incorrectly.
                In addition, please specify the visual issues you have encountered with the current configuration. Some screenshots would be helpful.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.