Thursday, June 18, 2009

Menu control (Asp.net 2.0) is not displaying properly in Google chrome and IE8 (Beta).

Though the Asp.net 2.0 menu control was displaying fine in IE 6 and Mozilla, There were issues with mouse hover styles and alignment in Google Chrome and IE 8. I was scratching my head over and over for long.

Could find a solution to tackle this issue. This is really interesting.

The C# version of the solution is as follows:

( If you got a master page for the application / website, write this snippet in it's PreInit event )

protected void Page_PreInit(object sender, EventArgs e)
{
if (!IsPostBack)
{
if ((Request.UserAgent.IndexOf("AppleWebKit") > 0 ) || (Request.UserAgent.IndexOf("Unknown") > 0 ) || ( Request.UserAgent.IndexOf("Chrome") > 0 ))
{
Request.Browser.Adapters.Clear();
}
}
}

Happy hours ! It works for Chrome. Im trying for IE 8. Let me know if some one can give some ideas.

1 comment:

Dharmbir said...

Yup the solution is working for me also , but could you put some light what was the reason of this issue.