asp:Menu control does not work well in all browsers

Discussion in 'ASP .Net' started by AAaron123, Jun 12, 2009.

  1. AAaron123

    AAaron123 Guest

    I IE a menu item looks like:
    Events Calendar

    If I click it I get a dropdown list of other menu items.
    Just like in Windows.

    But in some browsers the menuitem looks like:
    Events Calendar Expand Events Calendar

    If I click it I get:

    Events Calendar Events Locations ^Up One Level

    Pretty ugly, I think.

    Anything I can do about that?

    I'm using the asp:Menu control.


    Thanks
     
    AAaron123, Jun 12, 2009
    #1
    1. Advertising

  2. "AAaron123" <> wrote in news:ex3slq16JHA.1716
    @TK2MSFTNGP03.phx.gbl:

    > I IE a menu item looks like:
    > Events Calendar
    >
    > If I click it I get a dropdown list of other menu items.
    > Just like in Windows.
    >
    > But in some browsers the menuitem looks like:
    > Events Calendar Expand Events Calendar
    >
    > If I click it I get:
    >
    > Events Calendar Events Locations ^Up One Level
    >
    > Pretty ugly, I think.
    >
    > Anything I can do about that?
    >
    > I'm using the asp:Menu control.



    I would personally consider using the CSS Friendly adapters and writing CSS
    to configure the menu rather than have the menu control output the ugly
    tables.

    This means you are "on your own", but there are plenty of menu scripts out
    there you can use and it is fairly easy to find CSS that will work for you.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    ******************************************
    | Think outside the box! |
    ******************************************
     
    Gregory A. Beamer, Jun 12, 2009
    #2
    1. Advertising

  3. AAaron123

    AAaron123 Guest

    Before I make the suggested changes I'd like to clear up something else that
    just occurred. Unless you think those changes will fix this too.

    After some debugging the following is true.

    In Sub Page_PreRender I do:

    Response.Write("<script type='text/javascript'>")
    Response.Write("</script>")


    The source in the browsers looks like:

    <script type='text/javascript'>var htmlStyle =
    document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
    = 'black';</script>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    ...

    When I removed that code from Page_PreRender my asp:Menu's drop-downs became
    white rectangles instead of a list of menu items.

    So I guessed that maybe if the DOCTYPE is not the first line it is ignored
    and removing the script line made it effective.

    Does that sound correct??


    So I removed the DOCTYPE line from my code and the drop-down menu list looks
    OK (with or without the script line)

    I guess the browser defaults to something different if there is no DOCTYPE.

    What is the that default?


    I'd be surprised if you ran across this before but do you have any idea what
    might be happening?


    Thanks
     
    AAaron123, Jun 12, 2009
    #3
  4. AAaron123

    AAaron123 Guest

    Since I posted I've changed to
    Page.ClientScript.IsClientScriptBlockRegistered

    but this problem is with the DOCTYPE ot asp:Menu

    The script line simply masked that problem.



    Thanks





    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "AAaron123" <> wrote in message
    > news:udpzi$...
    >
    >> Response.Write("<script type='text/javascript'>")
    >> Response.Write("</script>")

    >
    > Please don't use Response.Write to inject HTML or JavaScript into ASP.NET
    > pages. ASP.NET is object-oriented, not linear like ASP Classic, so you
    > have much less control over where the JavaScript ends up in the final
    > markup.
    >
    > The ClientScript classes are designed specifically for this:
    > http://www.google.co.uk/search?aq=f&sourceid=chrome&ie=UTF-8&q="ASP.NET"+ClientScript
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    AAaron123, Jun 12, 2009
    #4
  5. AAaron123

    AAaron123 Guest

    "Mark Rae [MVP]" <> wrote in message
    news:%23vfPd$...
    > "AAaron123" <> wrote in message
    > news:...
    >
    >> Anything I can do about that?

    >
    > In addition to Gregory's (correct, IMO) suggestion that you use the CSS
    > Friendly Adaptors version of the menu control (Google it...), you can use
    > the technique described here:
    > http://www.velocityreviews.com/forums/t386549-mac-and-aspnet-20.html to
    > make the asp:Menu webcontrol display properly in Safari / Chrome etc, and
    > you can use the technique described here:



    I created a PageEx class inheriting from System.Web.UI.Page and inserted
    Private Sub Page_PreInit(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.PreInit

    If (Request.Browser.Browser.Contains("Safari")) Then

    Me.ClientTarget = "uplevel"

    End If

    End Sub



    And that fixed Safari. Is that need because asp.net has the wrong capability
    for Safari?



    Also, I searched the internet and only found references to Safari.

    Do you know what to check for as far as other browsers that need "uplevel"?

    I mean is FireFox and Chrome the strings that I should use in my "if"
    ststement?

    Are there others?

    I expected to find such a list but did not.



    Thank a lot. This was an easy fix.

    Now I'll read more about Friendly Adaptors.








    > http://weblogs.asp.net/bleroy/archive/2009/03/23/asp-menu-fix-for-ie8-problem-available.aspx
    > to make it display properly in IE8.
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    AAaron123, Jun 13, 2009
    #5
  6. AAaron123

    AAaron123 Guest


    > >
    >> I mean is FireFox and Chrome the strings that I should use in my "if"
    >> statement?

    >
    > FireFox should be fine - not sure about Chrome...
    >

    FYI Chrome reports: AppleMAC-Safari
    like Safari does.
     
    AAaron123, Jun 16, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank Rizzo
    Replies:
    6
    Views:
    412
    Frank Rizzo
    Jan 15, 2004
  2. Francis Ardi
    Replies:
    3
    Views:
    447
    Sudsy
    Jul 10, 2003
  3. Francis Ardi
    Replies:
    0
    Views:
    478
    Francis Ardi
    Jul 10, 2003
  4. El Kabong

    Browsers, browsers! Quo vadis?

    El Kabong, May 11, 2007, in forum: HTML
    Replies:
    23
    Views:
    930
    dorayme
    May 13, 2007
  5. Thomas Mlynarczyk

    Does Array.sort() not work the same in all browsers?

    Thomas Mlynarczyk, Feb 22, 2004, in forum: Javascript
    Replies:
    12
    Views:
    176
    Lasse Reichstein Nielsen
    Mar 2, 2004
Loading...

Share This Page