We help IT Professionals succeed at work.

.NET Menu website not displayed properly on Macintosh computers

Medium Priority
Last Modified: 2011-10-19
I used the .NET menuitem command to create a menu for my website. I had expected .NET menuitem (a built in .NET tool) would display the menu correctly in the Safari browser, but it does not. I have attached a picture of the menu as it appears in the MAC and on the PC. I have also attached a code snippet.

Am I doing something wrong here, or is .NET menuitem really not completely compatible with Safari ? Help !

Thanks, Pete
<%@ Control Language="VB" ClassName="TopMenu" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
    Dim sqlstring, sqlstring1, NID, PID, EC, URL, EC1, URL1 As String
    Dim mwidth As Integer
    Dim MyConn As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
    Dim MyConn1 As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
    Dim MyTools As New Krylium.KryliumTools
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
 If not page.IsPostBack then
       ' Load top menu
        Dim cMenuItm As MenuItem
        Dim menuItm As MenuItem
        With Menu1
            'Menu Configuration
            .Orientation = Orientation.Horizontal
            .DisappearAfter = 1000
            .MaximumDynamicDisplayLevels = 10
            .StaticDisplayLevels = 1
            'Menu Color Scheme
                .StaticMenuItemStyle.CssClass = "MenuItem"
                .StaticHoverStyle.CssClass = "MenuItemOver"
                .DynamicMenuItemStyle.CssClass = "SubmenuItem"
                .DynamicHoverStyle.CssClass = "SubmenuItemOver"
                .StaticMenuItemStyle.HorizontalPadding = 5
                .StaticMenuItemStyle.Width = 120
                .StaticMenuItemStyle.Height = 30
                .StaticEnableDefaultPopOutImage = False
            'Menu Dynamic Events
                .DynamicMenuItemStyle.Width = 120
                .DynamicMenuItemStyle.HorizontalPadding = 5
                .DynamicMenuItemStyle.Height = 20
        End With
        If MyTools.GetLanguage = "english" Then
            sqlstring = "Select M.ID, M.EnglishCaption, M.width from menuitem M, roles U WHERE (M.ParentItemID = 'Menuroot') and (U.ChannelID = '" & Session("Leaguenum") & "') and (U.RoleID = '" & Session("Rolenum") & "') and (CHARINDEX(M.PermissionID, U.PermissionIDs) > 0) ORDER BY M.SortOrder"
            sqlstring = "Select M.ID, M.FrenchCaption, M.width from menuitem m, roles U WHERE (M.ParentItemID = 'Menuroot') and (U.ChannelID = '" & Session("Leaguenum") & "') and (U.RoleID = '" & Session("Rolenum") & "') and (CHARINDEX(M.PermissionID, U.PermissionIDs) > 0) ORDER BY M.SortOrder"
        End If
        Dim cmd As New SqlCommand(sqlstring, MyConn)
        Dim MyReader As SqlDataReader = cmd.ExecuteReader()
        While MyReader.Read()
            NID = MyReader.GetString(0)
            EC = MyReader.GetString(1)
            mwidth = MyReader.GetInt16(2)
            'Create new root Item
            menuItm = New MenuItem
            menuItm.Text = EC
            menuItm.Selectable = False
            If MyTools.GetLanguage = "english" Then
                sqlstring1 = "Select M.EnglishCaption, M.URL from menuitem M, roles U WHERE (M.ParentItemID = '" & NID & "') and (U.ChannelID = '" & Session("Leaguenum") & "') and (U.RoleID = '" & Session("Rolenum") & "') and (CHARINDEX(M.PermissionID, U.PermissionIDS) > 0) ORDER BY M.ParentItemID, M.SortOrder"
                sqlstring1 = "Select M.FrenchCaption, M.URL from menuitem M, roles U WHERE (M.ParentItemID = '" & NID & "') and (U.ChannelID = '" & Session("Leaguenum") & "') and (U.RoleID = '" & Session("Rolenum") & "') and (CHARINDEX(M.PermissionID, U.PermissionIDs) > 0) ORDER BY M.ParentItemID, M.SortOrder"
            End If
            Dim cmd1 As New SqlCommand(sqlstring1, MyConn1)
            Dim MyReader1 As SqlDataReader = cmd1.ExecuteReader()
            While MyReader1.Read()
                EC1 = MyReader1.GetString(0)
                URL1 = MyReader1.GetString(1)
                'Add Child Items
                cMenuItm = New MenuItem
                If EC1 = "separator" Then
                        cMenuItm.ImageUrl = "~/images/childmenuseparator.jpg"
                        cMenuItm.Selectable = False
                        cMenuItm.Text = EC1
                        cMenuItm.NavigateUrl = URL1
                        '   cMenuItm.Target = "_blank"
                End If
            End While
        End While
        end if
    End Sub
<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body>
<asp:Menu ID="Menu1" runat="server" />

Open in new window

Watch Question

It is not too odd!
Microsoft based technologies...
Do not expect too much!

An alternative way is to use third-party menu components.
Like Telerik, SoThink DHTML Menu or ...
They work well of four major browsers (IE, FireFox, Safari, Opera)
I program for IE, Firefox & Safari, if you program for all three you going to have to compromise in some areas. This control is probably just one of a dozen that will not work in Safari. I use to only program for IE and Firefox until I went Mac this past year, some of the applications I have written do not render properly in Safari. I truly believe that Safari is the best browser made, fast with many features. I wouldn't blame Apple on this one.

I have found the solution to the problem. Funny, I had searched using Google on my PC for hours and could not get a solution, and the first search I did with Google on my Mac brought me to the solution.

The issue is not that ASP.NET cannot support interoperability, it is that that Microsoft does not do their due diligence to keep the list of interoperable browsers (and their capabilities) up to date. There is a file (Browser caps) that Microsoft is supposed to be populating and registering the browser versions with their capabilities. The way Microsoft has designed it, if they do not register a new browser in their capabilities matrix, ASP.NET 2.0 assumes it has very little capability and does not render advanced functions (like menus) at all.

In order to solve the problem, I needed to create a file in the App_Browsers folder (which I called safari.browser) which contained the following code:

     <browser refID="safari1plus">
            <adapter controlType="System.Web.UI.Webcontrols.Menu" adapterType="" />

It works great !

I found the solution in a post at forums.asp.net/t/941229.aspx
Nice and easy!

Closed, 500 points refunded.
Community Support Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.