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