locked
Safari browser and asp:menu RRS feed

  • Question

  • User-1482495230 posted
    Hey folks,
    Having trouble getting the asp:menu to work right on OS X using Safari.
    The mouseovers simply do not work, and when you click on one of the links, the menu disappears completely.
    I do have some code-behind on the menu for itemCreated (to cause the parent to be highlighted as selected when a child is selected)

    Any ideas?
    -Kevin

    Monday, November 28, 2005 4:02 PM

All replies

  • User-1830547969 posted
    Kevin,
      This is a known issue.  First off, Safari gets served the menu adaptor which is fully functional but does not support the dynamic fly-outs.  Instead you must click on menu items to see the sub menus.  Secondly, there are some style issues with Safari and Menu.  I've posted on my blog about these issues and potential workarounds: 

    http://weblogs.asp.net/dannychen/archive/2005/11/21/431121.aspx

    --
    Danny
    Tuesday, November 29, 2005 4:50 PM
  • User-1482495230 posted
    Hey Danny,

    Thanks for the reply - I actually checked out your blog - it's the only reference to this problem on the net. (and made your first comment!).  The problem seems to be if they click on a menu item that should have a dynamic list appear, then the whole menu disappears. If they click on a menu that doesn't have any sub-menu, it will redirect them fine.

    I think I read somewhere, that if we do the downlevel correctly, if they click on a menu item, than it will make the sub-menu pop-up and they can select the sub-link. Am I wrong?


    Wednesday, November 30, 2005 5:15 PM
  • User-1830547969 posted
    Yes, that is the exact symptoms of the issue I was describing in my blog post.  The recommendations I made will help you work around this issue.
    --
    Danny
    Thursday, December 1, 2005 1:42 PM
  • User-1872729852 posted

    Hi Danny,

    I tried to do what your blog said. but still I am getting the down-level menu. can you give us a short example which would work on safari?

    thank you.

    ravi

     

    Thursday, January 5, 2006 11:18 PM
  • User-1262327014 posted

    Hi there

    I disagree with Danny's work around - there is a much simpler way to get this working.

    The asp.net menu control is actually cross browser complaint, and does work correctly on Safari. The problem is how asp.net identify's the browser, and determines the javascript and rendering requirements for it.

    Asp.net identify's the browser by comparing it's caps to entries found in the machine.config and web.config. As browsers get updated, these string identifiers change, and so asp.net misreports what browser it is, causing it to render incorrectly on most browsers. Microsoft have outsourced the updating of browser caps to another company - and that company is not doing anywhere near a decent job at keeping theses up to date.

    Good news is that you can set this up yourself by adding entries to the web config. There are plenty of listings available on the net, and I suggest searching Google for "Browser Caps ASP.NET web.config Safari".

    Hope this helps

    Doug

    Friday, January 6, 2006 2:35 AM
  • User-1830547969 posted

    Sorry for not being clearer.  Safari and IE5.0 are considered downlevel browsers by ASP.NET.  By default you won't get rich renderings for either of those.  Part of the reason is that for much of the development of ASP.NET, Safari did not support all the features necessary to render the uplevel menu.  What I am trying to help out with in my blog is the issue where you click on a link in the downlevel menu and the menu seems to disappear. 

    However, all that said, what Doug has mentioned is correct, you can modify browser caps to push try and push a richly rendered menu to Safari.  But, be warned, while this may work for you, it is not a supported scenario and there are a couple of known issues with doing this.  Not supported means that any issues you encounter after this modification is up to you to investigate and find workarounds for.  I'm certainly not saying it's a bad idea, if it works for you, that is great and I'd love to know about it.

    Future versions of ASP.NET and the Menu control will evaluate what features have become availible in Safari and render appropriately. 
    --
    Danny

    Friday, January 6, 2006 1:39 PM
  • User-1872729852 posted

    Hi Doug,

    I tried editing the browsercaps and it does not seem to do the trick for me. Have you got is working on safari. Can you post your code please?

    ravi

     

    Sunday, January 8, 2006 4:54 PM
  • User159659314 posted

    Hello Doug,

     

    I also gave the browsercaps a try but Safari still renders the downlevel menu :(
    Would be great if you could post what you have done to make Safari render the menu like IE6 does.

    I have used the following browsercaps:
    http://www.codeproject.com/aspnet/browsercaps.asp

    and added

    <case match="AppleWebKit/412.9">
      version="2.0.3"
      majorversion="2"
      minorversion=".0"
    </case>


    I have also tried
    http://slingfive.com/pages/code/browserCaps/

    Dieter

    Monday, January 16, 2006 4:42 PM
  • User-1262327014 posted

    Hi Guys

    This is what i use for safari:

    <case match="AppleWebKit/(?'version'(?'major'\d?)(?'minor'\d{2})(?'letters'\w*)?)">
                    browser=AppleWebKit
                    version=${version}
                    majorversion=0${major}
                    minorversion=0.${minor}
                    frames=true
                    tables=true
                    cookies=true
                    javascript=true
                    javaapplets=true
                    ecmascriptversion=1.5
                    w3cdomversion=1.0
                    css1=true
                    css2=true
                    xml=true
                    tagwriter=System.Web.UI.HtmlTextWriter
                    <case match="AppleWebKit/(?'version'(?'major'\d)(?'minor'\d+)(?'letters'\w*))(.* )?(?'type'[^/\d]*)/.*( |$)">
                        type=${type}
                    </case>
                </case>

    Cheers

    Tuesday, January 17, 2006 2:27 AM
  • User159659314 posted

    Hello Doug,

    thanks for your reply.

    Even with the browercaps you have provided, Safari still renders the downlevel menufor me.
    Does it really render the uplevel menu in Safari for you?

    Best regards,

    Dieter

    Thursday, January 19, 2006 5:16 PM
  • User-1704081097 posted

    I have modified my web.config to have the browsercaps info for safari in there, but, while, a test page does give me the expected information for Safari, Safari still does not render the the dynamic submenu items any differently (there is no submenu shown on hover or click and the on click the menu disappears entirely).

    Has anyone heard anything new on this topic? 

    Monday, March 6, 2006 8:51 AM
  • User-430413477 posted
    I cant get it to work either.

    But I stopped the menu form disappearing. I noticed if I changed the Value="New Items" of the menu item the menu disappeared, if i left it at "New Items" it didn't.

    Big deal though the sub menus still do not work.
    Tuesday, March 21, 2006 9:25 AM
  • User-430413477 posted

    If you put ClientTarget="uplevel" in the page directive <%@ Page ClientTarget="uplevel" ......%> Safari works totally!!!!!

     

    Thursday, March 23, 2006 6:48 PM
  • User-430413477 posted

    You could also put it in the preint event...

      Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
            If InStr(Request.ServerVariables("http_user_agent"), "Safari") Then
                Page.ClientTarget = "uplevel"
            End If
        End Sub

    Thursday, March 23, 2006 7:45 PM
  • User-1872729852 posted
    thanks craigbtx. You solved a long time problem
    Thursday, April 6, 2006 3:20 AM
  • User467088301 posted

    I followed this thread - incredibly helpful...but with the uplevel browser I only get the first item in the submenu's - I can still hover over the "invisible" items, select them and navigate from them...

    Anybody else seeing this symptom??

    Also, is the browsecaps entry still needed with the ClientTarget Page directive?

    Tuesday, August 1, 2006 6:08 PM
  • User-430413477 posted

    I have not experienced getting only the first item.

    I dont use browsercaps at all.

    Everything works fine!!!

    Wednesday, August 2, 2006 8:20 AM
  • User467088301 posted

    OK - figured this one out...

    If you use the DynamicMenuStyle in addition to DynamicMenuHoverStyle and DynamicMenuItemStyle the secondary menu is clipped. Remove the DynamicMenuStyle tag and everything works perfectly.

    Wednesday, August 2, 2006 12:18 PM
  • User1990486002 posted
    Thanks!  using the Page.ClientTarget = "uplevel" method worked perfectly.  I tried to edit the Mozilla.browser file by removing the asp:Menu control adaptor section for Safari browsers, but my changes had no effect even after I restarted IIS web services on the server.  Is there something else I need to do to get .browser file changes to take effect or is there some other mechanism in play that forces the down browser rendering of the asp:Menu control on Safari?
    Friday, December 8, 2006 3:17 PM
  • User2089478681 posted

    I'm wrestling with this Safari menu problem.  It's not helped by the fact that I don't possess a Mac and have to rely on e-mail correspondence with my cousin's cousin whom I only met over the Christmas holiday and who is kindly helping me out!

    I've put this:

     if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)

    Page.ClientTarget = "uplevel";

    into the Page_Init  MasterPage which contains the menu.  (Master pages don't have Page_PreInit). 

    But my cousin's cousin reports that my menu still doesn't work.

    Any suggestions?

    Wednesday, January 3, 2007 8:57 AM
  • User-430413477 posted

    You have to put it in EVERY pages Page_Preinit event. It will not work in a master page.

    Kind of a pain but better than other alternatives like browser caps etc which I could never get working.

      Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
            If InStr(Request.ServerVariables("http_user_agent"), "Safari") Then
                Page.ClientTarget = "uplevel"
            End If
        End Sub

    Wednesday, January 3, 2007 11:07 AM
  • User2089478681 posted

    Thanks for the advice, Craig.

    As you say it is a big pain.  Especially as ASP.NET seemed to promise an end to cross-browser difficulties!  Presumably Microsoft will fix this in a future release?

    Rather than repeat  the same code on every page, I have created a new class called PageBase

    public class PageBase: Page
    {
    	public PageBase()
    	{
    	}
        protected void Page_PreInit(object sender, EventArgs e)
        {
          if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
             Page.ClientTarget = "uplevel";
        }
    }
     

    and then changed all my ChildPages so that they inherit from PageBase, instead of System.Web.UI.Page

    Wednesday, January 3, 2007 11:51 AM
  • User2089478681 posted

    I now have this working and my relative has confirmed that the menu displays OK on Safari.

    However, the dynamic sub-menus do not fly out.  There is no  

    "Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" 

     in the HTML that is rendered. Instead when he clicks on a top level menu item, the whole page refreshes and returns with the second level menu and a (page up) link. Is that the best I can expect to achieve?

     

    Thursday, January 4, 2007 2:53 PM
  • User-58745887 posted

    According to the MS documentation, using tthe "uplevel" value for the ClientTarget attribute means that it should work properly in IE vers 4.0 and later, does anyone know about older versions of Mozilla, Firefox, etc. and how they are effected?

    Many thanks...

    Thursday, January 4, 2007 7:01 PM
  • User2089478681 posted

    I've just noticed that my previous post appears back-to-front, probably because I pasted some HTML into it.

    What I intended to say is that, by setting ClientTarget to uplevel for safari browsers, I have a menu which works, but not in the same way as for IE and FireFox. Specifically the sub menus do not fly out. The user needs to click on the top level menu and the page refreshes to display the sub menu, together with a "page up" link.

    What puzzles me is that if I specify ClientTarget="uplevel" for all browsers, then I get different HTML for  different browsers. The IE version includes onmouseout and onmouseover event handlers while the Safari version does not. This seems inconsistent with the documentation which says "If you do set this property, client browser detection is disabled and the page will use browser capabilities associated with the named alias"

    I feel like I'm trying to assemble a jigsaw of information but the pieces don'f fit together. Can anyone explain what's going on?

    Friday, January 5, 2007 3:20 AM
  • User-86993979 posted

    I did try this solution, which works for the most part:

    Create a PageBase Class, then inherit PageBaseClass on every page.

    This simply is unacceptable, especially given Microsoft claims cross-browser compatibility.

    Create a new page and forget to set Inherits PageBaseClass and the menus don't work.

    This and other threads have been going for nearly 2 years on this issue and Microsoft has not resolved a very basic and incredibly important issue.

    We're going to be pushing 500 pages on our new website, and we have to change EVERY page's code-behind? Oh, sure, a global Find/Replace makes it "quick" enough, but when new pages are added and one 'forgets' to modify the Inherits line; not good at all.

    [8o|]

    Here's my code snippet:

    'Global code for System.web.UI.Page

    Option Explicit On

    Option Strict On

    Imports Microsoft.VisualBasic

    Public Class PageBaseClass

    Inherits System.Web.UI.Page

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

    If Me.Request.ServerVariables("http_user_agent").ToLower.Contains("safari") Then Page.ClientTarget = "uplevel"

    End Sub

    End Class

     

    '===========================================

    'Page-level code

    Option Explicit On

    Option Strict On

    Partial Class Home

    Inherits PageBaseClass

    End Class

     

    Monday, February 19, 2007 12:05 PM
  • User-54243553 posted

    If you put ClientTarget="uplevel" in the page directive <%@ Page ClientTarget="uplevel" ......%> Safari works totally!!!!!

    You rock! That totally fixed the problem I was having! [Yes]

    Monday, February 19, 2007 9:56 PM
  • User-1018037865 posted

     Hello,

    maybe I can help you all with this issue as well. What I did to enable the asp:menu for Safari was to add a file called safari.browser to the App_Browsers folder. The contents of safari.browser are as follows:  

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

    Basically the refID matches a browser id in the original browser configuration files for the .Net framework. In our custom .browser file we override the control adapter settings for the asp:menu control for this specific browser.

    There's one catch. Safari will crash when the browser window is too small to contain all the items in the menu and you hover over then out of the menu. I can not confirm this is true for Safari in general, but I have consistently seen this behavior on a Mac with OS X 10.3 and Safari 1.3, so be sure to test this case. This might be the reason that Microsoft decided to render an alternative menu for Safari.

    Let me know how this works out for you, I'd appreciate any feedback on this solution. Thanks! 

    Monday, June 4, 2007 10:28 AM
  • User2044328722 posted

    Well fareplay to you craigbtx. I was trying to solve that for a while.

    Thanks

    Anthony

    Thursday, June 28, 2007 3:14 PM
  • User527223617 posted

    This one worked for me.

    http://www.big-o.org/?p=20

    Wednesday, July 4, 2007 3:46 AM
  • User-499440954 posted

    thanks a million time bro!, that solved all my issues.

    cheers

    Sunday, August 12, 2007 11:35 AM
  • User368629139 posted

    Awesome man that works perfect.... now If I can just fix the white space between my images :P

    Monday, August 13, 2007 5:02 PM
  • User-1997857422 posted

    Michaelvoo - This one gets written in ink in my "big book of tricks" for browser compatibility fixes.  That was an awesome find that just solved Mac display issues on four sites for me.  Thanks a googol!

     BTW, I tested for the Safari 1.3 crash problem you described, but using Safari 3.0.3, and it doesn't seem to be a problem any longer.  Static and dynamic menus dropped down on a horizontal menu, and on a different site the vertical .NET menu rendered just as well without a problem.

    Wednesday, September 19, 2007 6:44 PM
  • User878788052 posted

    Personally, changing the ClientTarget to "uplevel" is not a good fix for me.

    The ASP.Net menu control renders correctly on Safari; however, I noticed that HttpBrowserCapabilities now thinks the browser is <abbr title="Internet Explorer 5.0">IE5</abbr>.

    I have an "AlphaImage" control I'm using to display all of my alpha–transparent <abbr title="Portable Network Graphics">PNG</abbr> images. If the control detects <abbr title="Internet Explorer 5.0">IE5</abbr> it dynamically swaps out the img reference for a div with an <abbr title="Internet Explorer">IE</abbr>–only filter at runtime.

    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='image.png');

    Of course, since Safari does not support Microsoft's proprietary filters the PNGs do not show up.

    Monday, October 1, 2007 2:10 AM
  • User980304572 posted

    You could also put it in the preint event...

      Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
            If InStr(Request.ServerVariables("http_user_agent"), "Safari") Then
                Page.ClientTarget = "uplevel"
            End If
        End Sub

     Thanks craigbtx.

    It is working fine for me.

     

     

    Wednesday, October 17, 2007 5:40 AM
  • User820927210 posted

     Thanks, michielvoo.... Adding the safari.browser file to the App_Browsers folder with this is what solved my problem.

    ------------------------------------------------------------------------------------------

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

    ------------------------------------------------------------------------------

     Also for those who are using a StaticPopOutImageUrl and are experiencing a Spacing issue with Firefox and Safari, use a CssClass for the StaticMenuItemStyle for padding (Don't use the StaticMenuItemStyle's HorizontalPadding property)

    <StaticMenuItemStyle CssClass="staticMenuItem" />

    ---------------------------------------------------------------------------

    Monday, January 14, 2008 8:02 AM
  • User-565895123 posted

    <browsers>
    <browser refID="safari1plus">
    <controlAdapters>
    <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
    </controlAdapters>
    </browser>
    </browsers>
     Good fix for me. Certainly better than forcing the browser "up level". Three sites, same issue, same fix .. all work now. Love ya work :)
    Friday, February 15, 2008 6:49 AM
  • User-430413477 posted

    I'll have to try this, looks simple.

    But we had more problems than just menus so using the uplevel settings as shown below fixed ALL issues. Never any more complaints.

      Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
                           
            'Test for Safari or any other browser that is not recognized properly by ASP.NET 2.0

            If InStrRequest.ServerVariables("http_user_agent"), "Safari") > 0 Then
                Session("SetToUpLevelBrowser") = True
            Else
               Session("SetToUpLevelBrowser") = False
            End If

        End Sub


    In every page put......

      Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
                If Session("SetToUpLevelBrowser") Then
                   Page.ClientTarget = "uplevel"
                End If
        End Sub

    Friday, February 15, 2008 10:44 AM
  • User-874092093 posted
    Worked perfectly! I know this thread is old, but the solution is becoming more necessary with the abundance of iPhones out there. Thanks Michielvoo.
    Tuesday, April 15, 2008 9:12 PM
  • User-1983322376 posted

    Step1: Add App_Browser Folder in application

              right click on project add ASP.Net Folder - App_Browser

              right click on  App_Browser -- Add new item  --- Browser File  ( with name Safari.browser )

             Add this section in Safari.browser file and save the file.

    <browser refID="safari1plus">

    <capabilities>

    <capability name="xml" value="true" />

    </capabilities>

    <controlAdapters>

    <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />

    </controlAdapters>

    </browser>

    </browsers>

    And Try now your application..

    ~    Please Mark as Answer -If it makes you helpful ~        

    http://abhijeetkhake.blogspot.com

     

     

    Thursday, April 17, 2008 7:22 AM
  • User-430413477 posted

    I have not verified this but......

    THERE'S ONE CATCH. See below.

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

    THERE'S ONE CATCH. Safari will crash when the browser window is too small to contain all the items in the menu and you hover over then out of the menu. I can not confirm this is true for Safari in general, but I have consistently seen this behavior on a Mac with OS X 10.3 and Safari 1.3, so be sure to test this case. This might be the reason that Microsoft decided to render an alternative menu for Safari.

    Basically the refID matches a browser id in the original browser configuration files for the .Net framework. In our custom .browser file we override the control adapter settings for the asp:menu control for this specific browser.


     Also for those who are using a StaticPopOutImageUrl and are experiencing a Spacing issue with Firefox and Safari, use a CssClass for the StaticMenuItemStyle for padding (Don't use the StaticMenuItemStyle's HorizontalPadding property)

    <StaticMenuItemStyle CssClass="staticMenuItem" />

    Thursday, April 17, 2008 9:53 AM
  • User-575790503 posted

    Check out this link. http://hirentechie.wordpress.com/2008/05/16/aspnet-menu-control-in-mac-safari-browser/

     
    I have my menu in a user control.  I put this in the Page_Load of the user control and it works in Safari.   

     
    if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
            {
                Request.Browser.Adapters.Clear();
            }

    Thursday, May 22, 2008 10:33 AM
  • User-462664965 posted

     Hello,

    maybe I can help you all with this issue as well. What I did to enable the asp:menu for Safari was to add a file called safari.browser to the App_Browsers folder. The contents of safari.browser are as follows:  

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

    Basically the refID matches a browser id in the original browser configuration files for the .Net framework. In our custom .browser file we override the control adapter settings for the asp:menu control for this specific browser.

    There's one catch. Safari will crash when the browser window is too small to contain all the items in the menu and you hover over then out of the menu. I can not confirm this is true for Safari in general, but I have consistently seen this behavior on a Mac with OS X 10.3 and Safari 1.3, so be sure to test this case. This might be the reason that Microsoft decided to render an alternative menu for Safari.

    Let me know how this works out for you, I'd appreciate any feedback on this solution. Thanks! 

    I just wanted to let you know (even though this is a very old thread) that you saved me so much time. Your solution fixed my problem perfectly. I had the same problem as the OP. There's tons of functionality in the .browser files that I wish I knew from day one. They have fixed so many of my Safari issues.
    Thursday, May 22, 2008 4:34 PM
  • User1787531537 posted

    works for me (App_Browsers) safari.browser

    Tuesday, August 26, 2008 4:48 PM
  • User-435300876 posted

    In let's say a menu that you have inheriting from asp menu and this issue has been observed.

     protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);

                //HACK: Microsoft's Safari menu adapter is not good at all
                if (this.Adapter != null)
                {
                    Page.Request.Browser.Adapters.Remove(typeof(Menu).AssemblyQualifiedName);
                }
            }  

    This won't have the disability of removing wanted browser adapters either. I also suggest a safari.browser file as described above for efficiency, but this will execute if you have a shared dll or something and you are worried about others forgetting that file. In other words, if the safari.browser file is there, this.Adapter would be null.

    This should work for all browsers because it will always remove the adapter if it is found. You may also try placing this in global.asax or somewhere else more useful.

     

    Wednesday, September 3, 2008 4:42 PM
  • User1447931844 posted

    i just notice using the Page.ClientTarget = "uplevel" will create problems for google bots when indexing your page, any alternative solution for this?

    Thursday, September 4, 2008 3:01 PM
  • User-1913941252 posted

    This has saved me hours of work thanks michielvoo - it works for Chrome too!

    Tuesday, September 16, 2008 8:43 AM
  • User2008450772 posted

    Wow!! It works for me too .. thanx a lot michielvoo .. very easy way rather than hitting all the pages.[Yes]

    Friday, March 27, 2009 12:26 PM
  • User74026492 posted

    I had the same problem. The following worked for me:

    if (Request.UserAgent.IndexOf("AppleWebKit") > 0)

    {

    Request.Browser.Adapters.Clear();

    }

    Saturday, March 28, 2009 4:34 PM
  • User1747761241 posted

    You can change the base page class then inherit all your pages from it.  Search on the web for uplevel safari   http://search.msn.com/results.aspx?q=uplevel+safari+asp.net&FORM=MSNH11

    Then uplevel chrome and safari.  Here's my post on it.  http://www.gosylvester.com/blog.aspx?id=11

    Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)

    Dim j As String = Page.Request.ServerVariables("http_user_agent").ToLower()

    If j.Contains("safari") Or j.Contains("chrome") Then

    Page.ClientTarget = "uplevel"

    End If

    MyBase.OnPreInit(e)

    End Sub

    My self I could no longer bear the strain of the 12k bytes the asp.net menu was pushing...

    Saturday, March 28, 2009 6:28 PM
  • User-430413477 posted

    This is a great solution, "You can change the base page class then inherit all your pages from it"

     But I found that this does not work when using code behind pages, or at least I couldn't get it to work.

    When I didn't use code behind pages it work right away.

     

     

    Sunday, March 29, 2009 9:22 AM
  • User1747761241 posted

    You can change the base page class then inherit all your pages from it.  Search on the web for uplevel safari   http://search.msn.com/results.aspx?q=uplevel+safari+asp.net&FORM=MSNH11

    Scan and replace System.Web.UI.Page with your page class in your project.

     

    Sunday, March 29, 2009 9:12 PM
  • User1477134808 posted

    hey all

    did anyone ever figger out how to get safari to work WITH dynamic menu styling?
    do i have to give that up on safari just cause its safari?

    uplevel only worked for me as long as i didnt have dynamic menu styling...

    your input greatly appreciated

    thanks
    toy


     

    Sunday, April 26, 2009 12:34 AM
  • User207107715 posted
    And what about Chrome?
    Sunday, May 3, 2009 9:03 AM
  • User-1274621011 posted

    safari.browser works perfectly on all my websites, inc those with multi level dynamic styles, thanks alot 

     

    Monday, December 7, 2009 11:06 AM
  • User-1770337992 posted

    Thank you  very much . I have same type of problem and your answer help me .

    Thursday, January 14, 2010 6:47 AM
  • User421353627 posted

    Rather than use a custom base page class that you force every page to inherit from to contain the pre-init code you should as a Global.asax file to your project and add the following code to it:

    void Application_PreRequestHandlerExecute ( object sender, EventArgs e )
    {       
        if ( this.Request.ServerVariables[ "http_user_agent" ].Contains ( "Safari" ) )
        {
            HttpApplication application = sender as HttpApplication;
            System.Web.UI.Page page = application.Context.CurrentHandler as System.Web.UI.Page;
                
            if ( page != null )
                page.ClientTarget = "uplevel"; //this.Page.ClientTarget = "uplevel";
        }
    }
    


     

    Thursday, January 28, 2010 1:55 PM
  • User-430413477 posted

    This is simple

    Adding the safari.browser file to the App_Browsers folder with this is what solved my problem.

    ------------------------------------------------------------------------------------------

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

    Thursday, January 28, 2010 4:51 PM
  • User-1246105563 posted

    protected void Page_PreInit(object sender, EventArgs e)

    {

     string str = Request.ServerVariables["http_user_agent"].ToUpper();

     if (str.Contains("SAFARI"))

    Page.ClientTarget = "uplevel";

     }

    This works like a charm, thanks

    Monday, March 8, 2010 2:11 AM
  • User465354118 posted

     Hello,

    maybe I can help you all with this issue as well. What I did to enable the asp:menu for Safari was to add a file called safari.browser to the App_Browsers folder. The contents of safari.browser are as follows:  

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

    Basically the refID matches a browser id in the original browser configuration files for the .Net framework. In our custom .browser file we override the control adapter settings for the asp:menu control for this specific browser.

    There's one catch. Safari will crash when the browser window is too small to contain all the items in the menu and you hover over then out of the menu. I can not confirm this is true for Safari in general, but I have consistently seen this behavior on a Mac with OS X 10.3 and Safari 1.3, so be sure to test this case. This might be the reason that Microsoft decided to render an alternative menu for Safari.

    Let me know how this works out for you, I'd appreciate any feedback on this solution. Thanks! 

    I just wanted to let you know (even though this is a very old thread) that you saved me so much time. Your solution fixed my problem perfectly. I had the same problem as the OP. There's tons of functionality in the .browser files that I wish I knew from day one. They have fixed so many of my Safari issues.

    Unfoturnately the ability to press a thanks button appears to have gone from this thread, but a heart-fet thanks,  just the same, from me.

    Thursday, April 15, 2010 4:48 AM
  • User-238964167 posted

    After adding this one it's work for all browsers

     

    if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
    {
    Request.Browser.Adapters.Clear();
    
    }

    for IE8...

    Add css Proferty in StyleSheet

    .IE8Fix
    {
        z-index: 1000;

    }

     

    and add the css property as follows...

     

    <asp:Menu runat="server" >
    
      <DynamicMenuStyle CssClass="IE8Fix" />
    
    </asp:Menu>

    Wednesday, March 23, 2011 12:47 AM
  • User465354118 posted

    With net 4, and using the Menu's  List RendiringMode, Safari now works fine without my App_Browsers file. Cool

    Thursday, August 4, 2011 4:15 PM
  • User-1221795426 posted

    hi gozoliet

    i had same problem and i put following code into MasterPage Where i put asp:menu

    so here is the code try this

    if (!IsPostBack)
    {
    if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
    {
    Request.Browser.Adapters.Clear();
    }
           }
    i hope it will help you..
    Saturday, August 6, 2011 1:27 AM
  • User2054545310 posted

    With net 4, and using the Menu's  List RendiringMode, Safari now works fine without my App_Browsers file. Cool

    This fixed it on Android too... (.net 4)
    Thanks

    RenderingMode="List"

     

    Monday, January 9, 2012 11:46 PM
  • User1829879277 posted

    Hi Guys,

    Don't know whether this has been suggested here previously by anyone or not, but would like to add my comments too. It may be silly and wrong but it resolved one of my problem and hence posting here.

    Try using the Menu's  Table RendiringMode i.e. RendiringMode="Table"

    I was facing the problem of MailTo link not working properly on IE 8 browser on Windows 7. It was opening the provided email id in a browser window and was also opening my default mail client. But, the same code was working properly on IE 8 browser on Windows XP. And the cause was the Rendering Mode of the Menu control. By setting it to "Table" and changing the CSS accordingly was able to resolve the issue.

    I hope it may resolve this problem too..

    Tuesday, January 10, 2012 12:05 AM