0

I have a web site that was originally built using vs2008. We've recently upgraded to vs2010. When i converted the projects to vs2010 projects i told it NOT to update the target framework from 3.5 to 4.0. As far as i can tell from looking at all references and the project framework everything is still on 3.5 but for some reason my ASP.NET menus went from rendering html tables to spans. I know that in 4.0 they added Menu.RenderingMode property and defaulted it to List instead of Table but since everything i'm building is 3.5 not only should it render in Table mode but I can't even manually set it to Table mode. Anyone know a fix for this (preferably other than a css hack on the spans or upgrading to 4.0)? I would just upgrade to 4.0 but we aren't ready for that yet. I'm not even confident that would fix it since it's not rendering an ol or ul with li tags (a list), it's rendering spans.

Stewart Anderson
  • 333
  • 2
  • 14
  • Have you seen the DOC Type of the website? I think that the `table` tag in your new DOC type is outdated so it might be rendering all the tables as `spans`. Please try to look into that once. – uday Jan 23 '12 at 19:27
  • I've been using WinMerge to see differences in the html rendering (from vs2008 to vs2010). It looks like the doctype stayed the same – Stewart Anderson Jan 23 '12 at 19:31
  • One thing i forgot to mention is it looks fine in localhost from vs2010 but when published out to IIS (in our case IIS 7) we have the issue. And it looks fine in IE & Firefox but not Chrome. – Stewart Anderson Jan 23 '12 at 20:09
  • Another odd thing is when i view source from FireFox and IE the table is there but when i view source from Chrome - no table - just spans. – Stewart Anderson Jan 23 '12 at 20:14
  • 1
    try: http://stackoverflow.com/questions/277197/asp-net-menu-control-not-rending-correctly-in-safari – Brent Anderson Jan 23 '12 at 20:20
  • @BrentAnderson I wish i would have found that article a while ago. I don't know how i missed it after searching as much as i did but - that was it! We have a 3rd party solution in our website that was using the control adapters / .browser files in the app_browsers folder. – Stewart Anderson Jan 23 '12 at 21:06
  • No sweat. Happens to me all the time :) – Brent Anderson Jan 24 '12 at 03:25

1 Answers1

4

The menu rendering problem is not related to vs2008 to 2010 conversion. asp.menu control of asp.net 3.5 is not rendered properly in chrome and safari.

The easiest way to fix this for both Safari and Chrome is to include your own browser file in App_Browsers in order to disable this adapter.

 <browsers>
  <!-- Disable the Menu Adapter for the Safari browser without changing the root browser file -->
  <browser refID="Safari1Plus">
    <controlAdapters>
      <adapter controlType="System.Web.UI.WebControls.Menu"
               adapterType="" />
    </controlAdapters>
  </browser>
</browsers>

And Just paste the below code in the load event of Page or Master Page (if used).

if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
 {
   Request.Browser.Adapters.Clear();
 }
Shahdat
  • 5,343
  • 4
  • 37
  • 37
  • It does still seem to be related to vs2010 because this project works fine when published from vs2008 but not vs2010. I think it's dealing with the .browser files you and Brent mentioned differently (from vs2008 / vs2010) somehow - not sure how because the Request.Browser.Adapters.Clear() call fixed it. We already had the .browser files because of a 3rd party solution - just didn't notice or know what they are until now. – Stewart Anderson Jan 24 '12 at 05:22
  • Here I have span for vs2008 too. Anyway, the default browser file for ASP.NET points the Menu control to a special adapter for Safari browsers. Unfortunately ASP.NET parses the UserAgent from Chrome recognizes it as Safari. – Shahdat Jan 24 '12 at 06:16