locked
Chrome only renders menu first time RRS feed

  • Question

  • User-1640947118 posted

    I've been searching for this several days - I'm hoping someone out there can help.

    I'm using the css friendly menu adapter on a master page.  It looks fine on IE7 and Firefox. My problem is with Chrome - it only renders properly the first time the page is loaded after launching the VWD dev server - as soon as I click on a menu item or even just reload the page the menu looks like a poor rendition of the asp:menu control. I've even ascertained that something is different because the "view source" for the page is different - the first load it has the menu as expected, with ul and li - and with subsequent loads it is rendered as a table.


    As per my multiple searches, I've added the Request.Browser.Adapters.Clear() fix to the page load of the master page. This helped render the asp:menu control to begin with (before this the submenu items would display with the word "Expand" that then had to be clicked)

    I also tried using the ClientTarget="uplevel" fix to the pre-init of a single page (to test it out)  - did not appear to make a difference here either.

    I'm imagining that if I'm having this problem with Chrome then it's a problem with Safari as well, so I would like to get this issue resolved...


    Thanks,

    CB

    Friday, June 26, 2009 12:17 PM

All replies

  • User-1640947118 posted

    Still have not found the reason for this. However, I did load the pages on my commercial host (as opposed to only testing with the VWD dev server) - and the menu is rendering properly (ie, as an unordered list with the appropriate CSS class applied) in Chrome and FireFox (and IE).

    This is making testing a bit cumbersome, but at lease I can go live with this...

    If anyone does have any ideas as to why this happened please let me know - I'm afraid that maybe the dev server got corrupted somehow and now I don't know if I can trust other output...

    Thanks,

    CB

    Monday, June 29, 2009 12:37 AM
  • User2008068812 posted

    Did you ever find a solution to this problem? I seem to have managed to take it one step further than you - when I browse the website using chrome on the commercial web server, it messes up the menu for clients in other locations using different browsers. 

    I'm absoloutly stumped with this as it leads me to believe that chrome is somehow writing something to the server. 

    Monday, July 20, 2009 6:12 PM
  • User2008068812 posted

    It seems as though when the aspnet_wp (or WebDev.Webserver.exe, depending on config, probably) gets recycled, it re-sets the page so that images will load properly in supported browsers again.

    This doesn't really clear anything up for me, but it adds a bit of information to the subject.

    Monday, July 20, 2009 8:03 PM
  • User2008068812 posted

    Ok, I'm not 100% sure on this, but it looks as though this is the problem.

    For whatever reason, when a link in the menu is clicked using chrome, it appears as though it generates extra scriptresource and webresource files - which IE then apparently uses. Basically it seems as though all browsers from that point on seem to lose the stylesheet - which leads me to believe that it's not being rendered properly when the webresource files are compiled.

    I don't know what chrome would be sending to the server that would cause this - I stripped out the css friendly code, bashed together a some styles for the standard menu control and everything seems to be working properly.

     

    P.

    Wednesday, July 22, 2009 7:27 PM
  • User-1640947118 posted

    Sorry for not replying sooner - I've been off-line...

    I never did figure it out - for some reason chrome does render it properly on the comercial host (IIS 7, if I'm not mistaken). IE6 does NOT render it at all - the whole menu control does not display (but that was reported to me by mthe customer  - I do not have a way to test it out currently, so I don't know what the generated html really looks like)

    FWIW, if you can get it to work, there's a way to specify a skin to be used if the browser will not support the control adapter (or if you specify for it not to use the adapter). See here:

    http://www.asp.net/CSSAdapters/WalkThru/WalkThrough.aspx#SimpleMenu

    and here:

    http://www.asp.net/CSSAdapters/WhitePaper.aspx#SamplesUsingInYourWebSite

    (although I personally have not gotten the skin to work too well, but that could very well be my lack of knowledge on how to integrate css styles in the skin)

    But why does it seem to work for all other browsers that purport to be on a similar level of compliance? And why are we the only ones asking about this? :-)

    Good Luck,

    CB



    Wednesday, July 22, 2009 10:09 PM
  • User-1332784049 posted

    Hi!


    I had the same problem, and there's a simple fix, which I took from here:

    http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2009/02/13/asp-menu-server-control-cross-browser-compatibility-safari-chrome.aspx

    add this:

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



    to your Page_Init or Page_Load event (in master page if you want),

    and this will fix all the problems: the CSS rendering problem, the "rendering only first time" problem, and the not rendering dynamic menus at all problem...


    Have fun!

    Daniel

    Sunday, September 20, 2009 2:11 PM
  • User-1332784049 posted

    BTW, if you want to be more accurate and prevent possible Adapter problems of other controls, you can add a code block inside the IF, to search for the specific asp:Menu adapter, and kill it.

    Sunday, September 20, 2009 2:13 PM
  • User-1640947118 posted

     Thanks for the reply, but if you look at my initial post you'll see that I already tried that method (and added it to the page load of the master page)

    What has been working so far with the  VWD server (but I have not fully tested it live on the comercial host, so I did not update this thread) is adding the following to the pre-init of the base page (which I guess would be the equivalent of adding it to the pre-init of the master page if a base page is not used?)

        If (Request.UserAgent.IndexOf("AppleWebKit") > 0) Or (Request.UserAgent.IndexOf("Unknown") > 0) Or (Request.UserAgent.IndexOf("Chrome") > 0) Then
          Page.ClientTarget = "uplevel"


    This was cobbled from assorted sources - unfortunately I do not remember where so I can not credit them appropriately...

    Thanks anyway...

    Monday, September 21, 2009 1:05 AM
  • User-629888833 posted

    Hi!

    Did not work for me either...

    BR,

    Tony


    Friday, November 27, 2009 3:15 AM
  • User569295445 posted

    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";
             }

    visit my Blog Student Academic Blog Mark as Answerif Helps you

    Tuesday, January 5, 2010 12:47 AM
  • User569295445 posted

    http://forums.asp.net/p/1315588/2601454.aspx

    Tuesday, January 5, 2010 12:49 AM