Click here to Skip to main content
11,408,835 members (60,748 online)
Click here to Skip to main content

ASP.NET Menu Control Issue in Chrome and Safari

, 27 Jul 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
ASP.NET menu control not shown properly in Chrome and Safari


While using ASP.NET menu control at that time, Safari as well as Chrome did not render that control properly. That’s the reason why mouse over does not work properly in Chrome and Safari with ASP.NET menu control as shown in the below images.



While it's working perfectly with Mozilla Firefox and Internet Explorer.


Mozilla Firefox


As you can see, the look and feel of the main menu is different. Submenu does not show up. So what is the solution for this? I searched Google and found that these 3 solutions work perfectly.

Method 1

  1. Go to Solution Explorer in Visual Studio and add “ASP.NET Folder” named “APP_Broswers”.
  2. Add new item “Browser File” to this special folder and name it “safari.browser” for both browser Chrome as well as Safari.
  3. Now delete all per-added data from safari.browser file.
  4. Now add the following tags to that browser file:
        <browser refID="safari1plus"> 
              <adapter controlType="System.Web.UI.WebControls.Menu" 
              adapterType="" /> 
  5. Now, the only thing is that you need to save that file.


Method 2

The other solution is using Server side code. For fixing bug, we need to write these two lines of code to each and every Page's Page_PreInit event, or if MasterPage file is used, then there is no need to add these lines to each and every page, just copy and paste these lines to only MasterPage's Page_PreInit event. This code works for both Safari as well as Chrome.

protected void Page_PreInit(object sender, EventArgs e)
    ("Safari",StringComparison.CurrentCultureIgnoreCase) != -1)
        Page.ClientTarget = "uplevel";

OR Use this alternate code

protected void Page_PreInit(object sender, EventArgs e)
  if (Request.UserAgent.Contains("AppleWebKit")) 

After applying any of these changes, ASP.NET menu works properly in all browsers like Mozilla Firefox, Internet Explorer, Safari and Chrome.



Enjoy the trick!!!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tejas Vaishnav
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

QuestionIs it any change required for Safari in iPod? PinmemberMember 824462518-Mar-15 0:56 
AnswerRe: Is it any change required for Safari in iPod? PinprofessionalTejas Vaishnav18-Mar-15 5:45 
QuestionMenu not displaying properly in google chrome PinmemberMember 112887005-Dec-14 2:48 
AnswerRe: Menu not displaying properly in google chrome PinprofessionalTejas Vaishnav5-Dec-14 20:16 
QuestionThanks Pinmemberzanyar201031-Mar-14 9:34 
AnswerRe: Thanks PinprofessionalTejas Vaishnav31-Mar-14 20:44 
GeneralGreat post Pinmembertyczo20-Jan-14 4:42 
GeneralRe: Great post PinprofessionalTejas Vaishnav20-Jan-14 19:01 
GeneralMy vote of 5 PinmemberRowen Gonzales23-Sep-13 22:19 
QuestionThanks but it gives an error PinmemberGaryParkin5-Sep-13 5:06 
GeneralMy vote of 5 PinmemberN10K15-Mar-13 0:00 
QuestionConext menu PinmemberMember 812804019-Dec-12 20:34 
Questionthrown error.. Pinmemberravi teja .k18-Dec-12 5:38 
AnswerRe: thrown error.. PinmemberTejas Vaishnav18-Dec-12 23:24 
GeneralMy vote of 4 PinmemberRajendra Bhandari12-Dec-12 0:16 
GeneralRe: My vote of 4 PinmemberTejas Vaishnav12-Dec-12 23:17 
GeneralMy vote of 5 PinmemberVijaychauhan080616-Nov-12 20:22 
GeneralRe: My vote of 5 PinmemberTejas Vaishnav19-Nov-12 23:45 
GeneralNon-intuitive Pinmembercallcopse9-Nov-12 2:23 
GeneralRe: Non-intuitive PinmemberTejas Vaishnav19-Nov-12 23:45 
GeneralMy vote of 5 PinmemberAbdul Quader Mamun13-Aug-12 18:07 
GeneralRe: My vote of 5 PinmemberTejas_Vaishnav16-Aug-12 1:06 
GeneralRe: My vote of 5 PinmemberAbdul Quader Mamun16-Aug-12 1:46 
GeneralRe: My vote of 5 PinmemberAbdul Quader Mamun16-Aug-12 1:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.5 | Last Updated 27 Jul 2012
Article Copyright 2012 by Tejas Vaishnav
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid