As is the case most of the time, I’m posting now to tell you about a problem I’ve just fixed.
My asp.NET Menu Control was rendering perfectly in IE 7, but looked completely horrid in Chrome. My submenus also weren’t displaying on mouseover.
My code was fine because the menu did work perfectly in IE 7. The problem must, therefore, be with the browser.
Based on what I’ve found online researching this problem, it seems that ASP.NET renders controls in a specific way to allow for backward compatibility with older browsers. As it turns out, ASP.NET doesn’t have a “definition” for Google Chrome that tells it what the browser’s capabilities are. The end result being that the server renders the control incorrectly because ASP.NET doesn’t know what Chrome can do.
Given the explanation above, the solution seems obvious: Tell ASP.NET what Chrome can do.
To do this, you can follow these steps:
- Add the App_Browsers folder to your website
- Create a new Browsers file in this folder and call it Chrome.browser
- Comment out everything in the file and replace it with this:
|4||<adapter controlType=“System.Web.UI.WebControls.Menu“ adapterType=“” />|
All this basically does (as far as I can logically understand) is tell the server that Chrome can handle the Menu Control’s full functionality.