Carrotware.Web.UI.Controls.BasicControlUtils.MakeXUACompatibleFirst C# (CSharp) Method

MakeXUACompatibleFirst() public static method

public static MakeXUACompatibleFirst ( Page thePage ) : void
thePage System.Web.UI.Page
return void
        public static void MakeXUACompatibleFirst(Page thePage)
        {
            int iOrder = 0;
            bool bFoundEdge = false;
            HtmlMeta metaEdge = null;
            foreach (var c in thePage.Header.Controls) {
                if (c is HtmlMeta) {
                    HtmlMeta metaTest = (HtmlMeta)c;
                    if (metaTest.HttpEquiv.ToLowerInvariant() == "x-ua-compatible") {
                        metaEdge = new HtmlMeta();
                        metaEdge.HttpEquiv = metaTest.HttpEquiv;
                        metaEdge.Content = metaTest.Content;
                        bFoundEdge = true;
                        break;
                    }
                }
                iOrder++;
            }

            if (!bFoundEdge) {
                metaEdge = new HtmlMeta();
                metaEdge.HttpEquiv = "X-UA-Compatible";
                metaEdge.Content = "IE=edge,chrome=1";
            }

            if (metaEdge != null && iOrder > 0) {
                thePage.Header.Controls.AddAt(0, metaEdge);
            }
        }