More Group Sites
School Rankings
Jobless Net
Better Home
Enviro++


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

Problem with rendering asp.net menu control in Chrome and Safari Options · View
hong
Posted: Friday, September 23, 2011 8:58:12 AM

Rank: Administration
Groups: Administration

Joined: 11/23/2008
Posts: 335
Points: 711
Location: Australia
If you found your asp.net menu control is displayed correctly in IE and Firefox but not in Chrome and Safari, try the following:
Code:
         protected void Page_PreInit(object sender, EventArgs e)
         {
             // This is necessary because Safari and Chrome browsers don't display the Menu control correctly.
             // All webpages displaying an ASP.NET menu control must inherit this class.
             if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
                 Page.ClientTarget = "uplevel";
         }


To avoid adding the Page_PreInit() function on all your pages, override AddedControl() in your master page instead:

Code:
protected override void AddedControl(Control control, int index)
{
// This is necessary because Safari and Chrome browsers don't display the Menu control correctly.
// Add this to the code in your master page.
if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
this.Page.ClientTarget = "uplevel";

base.AddedControl(control, index);
}


The above code worked for me for quite long time, but it broke again. This time I made the asp.net menu compatible with Chrome browser as follows:
1. Add ‘App_Browsers’ folder on root of the website.
2. Add chrome.browser file with below code under the folder ‘App_Browsers’:
Code:
<browsers>
  <browser refID="safari1plus">
    <controlAdapters>
      <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
    </controlAdapters>
  </browser>
</browsers>


Related:
ASP.NET menu control not working in Chrome or IE 8
Sponsor
Posted: Friday, September 23, 2011 8:58:12 AM
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.480 seconds.