ASP.NET Menu rendering issue in Google Chrome

 

Now, that was weird!

Surprisingly, I jumped into a rendering issue with ASP.NET menu in Google Chrome and I observed following glitches:

  1. Sub-menu items were not displaying on hovering over the main menu (say Products)
  2. When I select the main menu item (Product), the respective sub-menu items are displayed horizontally, instead of listing vertically (on hover)

Here goes a sample screenshot

menu_issue

The solution is to check for Chrome user-agent string and clear the browser adapter mapping so that the control will be rendered irrespective of the client browser.

if (Request.UserAgent.IndexOf("Chrome") > 0)
{
    if (Request.Browser.Adapters.Count > 0)
    {
        Request.Browser.Adapters.Clear();
        Response.Redirect(Page.Request.Url.AbsoluteUri);
    }
}

The ControlAdapter provides a mapping between an ASP.NET Web Control and the adapter used to render the control in client browser.

If you are interested to dig deeper, then have a look at here and here.

Best way to use this code is to create a Base class inherited from System.Web.UI.Page and include this code in appropriate page event. Now, you can inherit this base class is those pages that require this piece of code.

Note: After clearing the Adapter for Chrome, I haven’t experienced any issues with other web controls so far. In case, if you are facing any issue, please feel free to share it.

Thanks

 

Back, Back, Back

 

Hoooo!!! How frustrating it was. I’s on to tight work schedule. Didn’t got any free time to be with my pet projects nor with my blog Sad smile. It’s really frustrating and suffocating, if you know what I mean!

Now, I’m pretty free from my tight schedule and will get enough time to blog as well (finger’s crossed). Got a lot of things to update and lot of exciting things to share!

Keep watching! I’ so excited and thrilled. Because, I can enjoy the free-DOM. Smile

Thanks!

 

VSAchievements

Visual Studio Achievements
abhilashca (132 Points)
  • Power Coder
    • Time For An Upgrade
      A solution takes 10 minutes to compile. Dag, that's one enormous solution!
      Friday, May 03, 2013
    • Suspicious
      Suspicious (10 Points)
      Use 5 preprocessor directives. Compiler commands -- aren't you fancy!
      Friday, February 22, 2013
    • Equal Opportunist
      Equal Opportunist (10 Points)
      Write a class with public, private, protected and internal members. It's all about scope. Uses FxCop
      Monday, January 21, 2013
    • On The Shoulders of Giants
      Reference 25 assemblies. Hey, why should you write it if someone else already did?
      Tuesday, January 08, 2013
    • Localization Guru
      Localization Guru (10 Points)
      Have 1000 localized values. Nice localization work!
      Thursday, January 26, 2012
  • Just For Fun
    • Save A Tree
      Save A Tree (5 Points)
      Print source code. My boss told me to. I swear!
      Monday, March 04, 2013
    • Obsessive Compulsive Disorder (OCD)
      Invoke the 'Close All But This' menu option 10 times. I mean, who invented those damn tabs anyway?
      Sunday, February 26, 2012
    • Lonely
      Lonely (5 Points)
      Code on a Friday or Saturday night. Coding? Tonight? Ouch.
      Saturday, February 04, 2012
    • Install and Register For Visual Studio Achievements
      Install the add-in and register with Channel9. You are up and running!
      Sunday, January 22, 2012
  • Windows 8
  • Don't Try This At Home
    • Overload
      Overload (0 Points)
      More than 10 overloads of a method. You could go with this or you could go with that. Uses FxCop
      Wednesday, February 13, 2013
    • Go To Hell
      Go To Hell (0 Points)
      Use of the goto keyword. Um, I heard it was a best practice that you weren't supposed to do that anymore.
      Friday, January 04, 2013
    • Scroll Bar Wizard
      Write a single line of 300 characters long. Who needs carriage returns? Uses FxCop
      Thursday, December 27, 2012
  • Unleashing Visual Studio
    • The Explorer
      The Explorer (5 Points)
      Start a debug session using step into (F11) more than 10 times. Ah, the power of F11. Every coder's best friend.
      Monday, February 27, 2012
    • Casual Observer
      Casual Observer (5 Points)
      Start a debug session using step over (F10) more than 10 times. I thank the debugger every day.
      Saturday, February 11, 2012
  • Good Housekeeping
    • Regional Manager
      Regional Manager (7 Points)
      Add 10 regions to a class. Your code is so readable, if I only didn't have to keep collapsing and expanding!
      Thursday, February 02, 2012
  • Customizing Visual Studio
    • Extensions Junkie Deluxe
      Install 10 extensions to Visual Studio. How can you find anything on a menu?
      Sunday, January 22, 2012
    • Extensions Junkie
      Install 5 extensions to Visual Studio. Extensibility rocks!
      Sunday, January 22, 2012

Month List

Tag cloud