Render your ASP.NET webpage in IE8 With simillar functionality of IE7

Description



Some of the controls like repeater control isn't working well in IE8 means you can realize the UI changes occured while opening the page with IE8. So If your ASP.net application is working fine in IE6 and IE7 ,But not working well in IE8 ,So if you want this functionality in IE8 then do as below.


There are two methods by which you can achieve this.

First one:

Go to IIS and spot your website and right click on it and go to properties and add a HttpHeader with HeaderName as ‘X-UA-Compatible’ and value as ‘IE=EmulateIE7’

Second one:

add this after head tag in each page

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

But make sure that no script tag and link preceding this one

you can also add meta tag programmatically in OnInit event

protected override void OnInit(EventArgs e)
{
//Always do the check before adding the meta tag
if (CheckBrowser("IE", 8))
{
HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "X-UA-Compatible";
meta.Content = "IE=EmulateIE7";
this.Page.Header.Controls.AddAt(0, meta);
}
}


/// Checks the browser.
/// </summary>
/// <param name="browserName">Name of the browser.</param>
/// <param name="browserMajorVersion">The browser major version.</param>
/// <returns></returns>

public static bool CheckBrowser(string browserName, int browserMajorVersion)
{
HttpBrowserCapabilities br = HttpContext.Current.Request.Browser;
if (br.Browser.ToUpper().Equals(browserName) && (br.MajorVersion == browserMajorVersion))
return true;
else
return false;
}


Note:All these applies when compatibility mode isn't selected in IE8.(To view compatibility mode go to tool and then compatibility view setting)


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: