Fix ASP.net menu in Safari and Chrome

.Net, HTML Add comments

If you use the standard ASP.NET menu (or toolbar) in your web application, it works well in most browsers except for Safari & Chrome. In these 2 browsers, each menu item appears on a new line.

The fix I found was placing the following code in my MaterPage code-behind:
if (Request.UserAgent.IndexOf(“AppleWebKit”) > 0)
        {
            Request.Browser.Adapters.Clear();
        }

If you are not using a Materpage:
protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.UserAgent != null && Request.UserAgent.IndexOf(“AppleWebKit”, StringComparer.CurrentCultureIgnoreCase) > -1)
        {
            this.ClientTarget = “uplevel”;
        }
    }

The solution is adapted from this site (Thank you):
http://weblogs.asp.net/joshuajohnson/archive/2008/01/23/how-do-i-overcome-the-dreaded-safari-asp-net-menu-conundrum.aspx

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in