Welcome to MSDN Blogs Sign in | Join | Help

Giorgio Sardo Blog

The Music Box of the Web
ASP.NET Menu and IE8 rendering white issue

If you are using the ASP.NET Menu control, you might encounter under certain circumstances an issue where the menu appears as a white box in IE8 Standards Mode.

image

What IE8 is doing IS correct (by design), in the sense that in Standards mode IE8 is following the standards. Specifically, (element).currentStyle.zIndex returns "auto" in Standards mode when zindex has not been set. The ASP.NET Menu control assumes a different value.

I’d like to suggest a few possible workarounds to solve quickly the issue (note, you can use either one of them, depending on your scenario):

  1. Overriding the z-index property
  2. Using CSS Friendly Control Adapters
  3. Adding the IE7 META tag to the website

1 – Overriding the z-index property

You can manually set the z-index property of the Menu items using the DynamicMenuStyle property of the asp:Menu control (note lines 9-14 and 20). Full source code is:

   1: <head runat="server">
   2:     <title></title>
   3:     <style type="text/css">
   4:         body
   5:         {
   6:             background-color: Silver;
   7:         }
   8:     </style>
   9:     <style type="text/css">
  10:         .IE8Fix
  11:         {
  12:             z-index: 100;
  13:         }
  14:     </style>
  15: </head>
  16: <body>
  17:     <form id="form1" runat="server">
  18:     <div>
  19:         <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
  20:             <DynamicMenuStyle CssClass="IE8Fix" />
  21:         </asp:Menu>
  22:         <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
  23:     </div>
  24:     </form>
  25: </body>

This solution is the least intrusive, but it require a page-by-page update (unless your menu is a Master Page).

2 – Using CSS Friendly Control Adapters

Thanks to Tim for this solution. In order to add the CSS Friendly adapter to your project, you will need to:

  1. Download CSSFriendly.dll and CSSFriendlyAdapters.browser from here.
  2. Inside your project, add a reference to CSSFriendly.dll.
  3. Add the special folder App_Browsers to your project, and copy the file CSSFriendlyAdapters.browser.

The CSS Friendly Control Adapters will render all the listed controls (Menu, TreeView, DetailsView, …) using CSS and HTML standards.

3 – Add the IE7 META tag to the project

By default, Windows Internet Explorer 8 will attempt to display content using its most standards-compliant mode, the IE8 Standards mode. However you can still switch to the IE7 Standards mode adding a particular META TAG to the head of the page:

   1: <html xmlns="http://www.w3.org/1999/xhtml">
   2: <head runat="server">
   3:     <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
   4:     
   5:     <title>IE8 ASP.NET Fix</title>
   6: </head>
   7: <body>

Using the tag, the website in IE8 will look and work in the same way as it does in IE7.

You can do a “live test” of this feature without the need to modify the page, using the new IE8 Developer Toolbar (press F12 to open the toolbar, and switch the Document Mode to IE7 Standards).

image

Note that you can set up the META tag at page level, at web.config level, or in IIS, or in Apache, …

What happens next?

The ASP.NET team is currently working on this issue and we will most likely create an official KB to address this issue before IE goes RTW.

EDIT: Hotfix are now available. Check here. 

Thanks to all the community feedbacks we received so far.

Technorati Tags: ,,
Posted: Sunday, February 01, 2009 10:59 PM by gisardo

Comments

Kevin Daly said:

Thanks, that's very helpful.

I'd been avoiding using the ASP.NET menu control in IE8 Standards mode since I tried it in Beta 1 - back then using the Menu caused numerous JavaScript errors, so anything that can be fixed with a simple style is a vast improvement.

On the subject of compatibility - I just now remembered to check the AJAX control toolkit extenders - once again, the situation is now greatly improved (in fact everything I tried worked fine - the opposite of the situation the first time I checked). That's quite a relief.

# February 1, 2009 7:38 PM

ASPInsiders said:

Since I’ve run into this issue myself, I thought I’d share a blog post that offers several possible workarounds

# February 2, 2009 10:09 AM

Selvaganapathy said:

THANK YOU VERY MUCH!!!

This solution very useful to me.

I Just apply "z-index: 100;" in CSS file. Now working good.

# February 3, 2009 7:45 AM

Siderite said:

I have met with the same issue and have decided to use the CSS Friendly Adapters. However, the menu is only looking acceptable in IE8 if the Compatibility View setting is set. Otherwise the menu is rendering dynamic div over the old ones.

# March 9, 2009 9:00 AM

maya said:

Helped me so much..Thank You..

# March 12, 2009 3:13 AM

IEBlog said:

Reports of broken sites are an important part of the feedback the IE team receives from the community.

# March 12, 2009 9:59 PM

Gaurav Mahajan said:

Thanks very much. This solved my menu problem. Keep on doing and explaining related issues.

Thanks again.

# March 15, 2009 12:47 PM

JimmyS said:

Setting the DynamicMenuStyle z-index worked perfect. Thanks.  I was giving up on using the menu control for sub menus after getting nowhere.

# March 19, 2009 3:04 AM

Karlo said:

Dear Giorgio,

Has this issue been adressed by the ASP.Net team, now that IE8 has gone live? I am the owner of a webbased application and would have my developers spending as little as time necessary for fixing this bug (€€€!!!)

Would be great, thanks for your help!

Karlo

# March 20, 2009 9:13 AM

Around and About .NET World said:

Primi problemi per Internet Explorer 8

# March 20, 2009 1:03 PM

Around and About .NET World said:

Il nuovo motore di rendering di Internet Explorer 8 comincia a mietere le prime vittime… Il primo a cadere

# March 20, 2009 1:03 PM

Mark Rodrigues said:

Hi Giorgio,

Thanks for that. It was the only problem I had on my site with IE.

Just to clarify, is this actually a bug in IE8 or is this IE8 being more true to THE standard ... whatever THE standard happens to be these days :)

Thanks again.

# March 21, 2009 1:32 AM

sandy said:

Thanks Giorgio!  The DynamicMenuStyle option worked for me :)

# March 21, 2009 11:45 AM

gisardo said:

Thanks all for the feedbacks.

@Mark: IE8 by default use the new layout engine, that has been designed to be 100% standards compliant with CSS 2.1. (See more at my MIX session, A Lap around IE8).

@Karlo: we will soon release (and distribute) an hotfix that will fix this issue.

If I look at this issue, I think this as a clear sign that we, as Microsoft, finally committed to full interoperability with web standards. We understand that this will require an initial "extra work" for our developers, but in the long term is going to be a great return of investment for the entire community.

Thanks!

# March 21, 2009 1:23 PM

Mike Chase said:

Thanks so much I used the CSS solution and it works. Thanks again, you saved the day!

# March 21, 2009 4:38 PM

Ivan said:

Thanks Giorgio!!!, very helpful article! :D

# March 22, 2009 10:59 PM

miguel molina said:

Giorgio:

Buon lavoro,

Grazie millie!

# March 23, 2009 1:58 AM

John H. said:

While I appreciate the workaround, I find it unacceptable that MS would release a browser that breaks applications developed using their own framework.  You guys need to get it together and work with the .NET team so you don't have thousands of developers wasting their time on issues like this.  My site is now viewable in every browser EXCEPT IE 8.  It's ludicrous.

# March 23, 2009 1:45 PM

Giorgio Sardo said:

Hi John,

if we look at what we did back in the past, moving from IE5 to IE6 to IE7...is exactly what you say: "Releasing a new product that don't break any previous application". Or, in other words, support legacy code.

With IE8 we took a different direction: being standards compliant by default. We did *a lot* of testing either with Microsoft applications and public websites. Unfortunately we are aware of a few things (like this) that could break, but:

1) We built an (IMHO) amazing compatibility support in IE8, that allows you to opt-in for the IE7 rendering engine. This is something that no other browser has ever done. Other browsers will just pretend you to update all of your code, if they do some breaking change....

2) We are releasing free tooling support, to help investigate and make sure website standard compliant.

We are aware that this will require some extra work from your side. At the same time, as we move forward, having IE8 being standards compliant will make your future website development experience much easier, thus will reduce development costs...

As I've written previously in this post we will release an hotfix for ASP.NET (note, not for IE...) that will fix this issue. The hotfix will also be included in future SP versions and finally in the next ASP.Net/OS releases.

Please keep on reporting your issues and feedbacks; our final goal is to make the developer community code faster across browsers and platforms ;)

Thanks,

Giorgio

# March 23, 2009 2:09 PM

Kassian said:

Hi Giorgio,

I tried all fixes and non worked, my menue is still not visible at all (asp:Menu VS 2005). No white square or anything. In IE 7 or FF it works just fine.

Any ideas?

Thanks for the help.

Kassian

# March 24, 2009 6:09 AM

Karlo said:

Ciao Giorgio,

Was the hotfix on ASP.net included in the update that came through not last night, but the night before? (European time). Servers went down, but anyway :-)

Or is it still pending?

Great to have a direct line with you in this way!

Mille grazie!

Karlo

# March 25, 2009 6:37 AM

gisardo said:

# March 25, 2009 4:58 PM

hunzonian said:

Hi, Thank you so much for this info! I added the IE8 css fix to my master pages/css file and it works without flaw.

Thanks!

hunzonian

# March 25, 2009 5:58 PM

Ossa Tech Blog said:

Internet Explorer 8 and ASP:Menu Control

# April 2, 2009 10:25 PM

Sherlock Ossa said:

Giorgio, thanks so much for the post.  I added the DynamicMenuStyle tonight in my master pages and it worked like a charm. I noticed this as a problem in the beta but thought it would be fixed before IE8 went live.

Thanks!

Sherlock Ossa

# April 2, 2009 10:30 PM

gisardo said:

Thanks Shelock. In fact the ASP.Net team did a great job releasing the hotfix one week before IE8 went RTW. :-)

# April 3, 2009 5:38 PM

peter plimpton said:

I was able to fix the problem with solution number 1 (Overriding the z-index property). Thanks for the example. I'm glad my menus were in master pages!

I remember having to fix the Safari problem with a addition to the AppBrowsers folder. The CSS Friendly Adaptor seems like a similar fix but you have to add the dll. Are people using this solution for other problems as well?

# April 3, 2009 10:43 PM

Balássy György (MSDNKK) said:

Ha a standard ASP.NET Menu vezérlőnek használjuk a dinamikusan kinyíló funkcióit, akkor készüljünk fel

# April 4, 2009 12:09 PM

IE8 Guy said:

Wow, thanks same me bunch of time

# April 12, 2009 10:23 PM

TI Dev said:

Solution no. 1 works for me on my Windows server 2003 machine but does not work on my Windows Server 2003 R2 Machine.

Solution No. 3 worked just fine for me on both the machines.

# April 20, 2009 10:14 AM

Karlo said:

Ciao Giorgio,

My developers have run the ASP.hotfix in my webapplication. Navigation works fine now in IE8 under XP, however in Vista it still doesn't work (without comptability-status). It appears that the release of SP2 for Vista and another patch have to be run before it all functions well under Vista. Is this correct? In that case: do you know when the official release of SP2 for Vista is planned?

Mille grazie!

# April 28, 2009 10:02 AM

wyatt said:

I just installed IE 8 this morning. One of the first things I noticed was that the page formatting now matched closely to my other browser. I check format in both browsers as I develop. Next I noticed the menu issue with the empty white space. I found the fix quickly on this block and added the dynamic menu css and z-index. It was a fast solution. I like working with standards, too.

# May 14, 2009 1:56 PM

Giorgio said:

Great! Thanks wyatt for your feedback.

# May 14, 2009 2:02 PM

Sanjit said:

Helped me so much..Thank You..

# May 30, 2009 3:08 AM

Morten said:

Thanks a million - the #1 solution did it for me. However - in general, I have an issue with asp:menu and the Safari browser. It looks weird. Do you have a solution?

# June 2, 2009 5:02 PM

Giorgio Sardo said:

Morten: what is the issue? I would suggest to check this post:

http://forums.asp.net/t/941229.aspx

Giorgio

# June 2, 2009 8:57 PM

Ginters said:

Nice job!

Boy am I getting tired or .NET controls and web browsers - the difference between 6 and 8 is large (just see png display).

Cheers

John

# June 16, 2009 6:06 PM

Joe said:

Thanks!  I had a client that complained about my menus not appearing on IE8.  I googled for "check if browser is ie8 asp.net", thinking that I would have to write some browser-specific code.  Guess which page was the very first on the list.  Yep, this one!

This is a MUCH simpler fix!  Thank you so much.

Note that it does have to be in the <DynamicMenuStyle/> tag and not the <DynamicMenuItemStyle/> tag.

Again, Thanks with a capital T! :)

Joe

P.S. I agree, John.  The difference between 6 and 8 is HUGE, and yet many people still use 6, and people are now using 8.  How to write code that suits them both?  :)

# June 18, 2009 8:19 AM

Chandralekha said:

Ciao Giorgio

Good Job!!

Thank u very much, i used cssclass in my master page

working fine.

# June 30, 2009 6:34 AM

Kylie Rasmussen said:

Why does the "z-index = 100;" fix the problem? Thanks for the help!

# July 6, 2009 6:27 PM

Jesse said:

The Z-index and the css fix did nothing for me...but the meta tag cleared the whole thing right up. Thanks!!

# July 9, 2009 5:05 PM

Dan-O said:

Thanks! The z-index change did the trick for me.

# July 15, 2009 11:29 AM

Riza said:

Used the meta tag before the style sheet and it work. None of the other fixes worked for me.

Will the hotfix solve the problem if I installed it to the IIS server machine? Or I have to install it to all the clients? Or Both?

# July 22, 2009 8:01 AM

gisardo said:

@Riza: you can install the hotfix only on the IIS Server Machine (since the rendering of the control is done on the server-side).

# July 22, 2009 6:35 PM

Priti said:

It's really helpful. Keep it up!!!

# July 30, 2009 7:41 AM

stecolna said:

Thanks a lot!!!

You suggestion has solved a bug in a web site I've developed.

Best regards

Stefano Colnaghi

# July 30, 2009 8:27 AM

Mike said:

Thank you!  This was so helpful!

# July 30, 2009 11:35 AM

Vishal Nigam said:

A great help for a problem which otherwise was looking major. You solution made it minor.

Thanks again.

# August 3, 2009 2:22 AM

Yogesh said:

Thank you very much. 'z-index' helped me to resolved the IE8 issue.

# August 4, 2009 2:01 PM

Giorgio Sardo said:

Priti, Stefano, Mike, Vishal, Yogesh: thanks for your feedback, I'm glad it helped!

-Giorgio

# August 4, 2009 2:10 PM

nada said:

Thank you so much  IE8Fix solve the problem

# August 7, 2009 10:04 AM

bob singh said:

Cheers - described in a simple way so that even i could understand it

nice one

# August 7, 2009 11:54 AM

nate said:

Overriding the z-index property worked for me. Thanks so much!

# August 14, 2009 1:47 PM

tiffany said:

Thanks very much. This solved my menu problem. Keep on doing and explaining related issues.

# August 16, 2009 3:39 AM

Rasim Çelik said:

Thank you so much! this was so helpfull. (from Turkey)

# August 18, 2009 3:53 AM

Rodney Kendall said:

YOU ARE AWESOME!  It is very difficult to find this resolution, until IE8 is added to the search criteria.  Once it is there, this solution is a life saver!

# August 19, 2009 9:54 AM

John Thompson said:

Your a life saver. Its just annoying (though predictable) that Microsoft couldn't read the standards documents in the first place.

# September 1, 2009 4:16 AM

Minal Shroff said:

I included the meta tag in all my aspx pages..works like a charm...thank you so much...

# September 1, 2009 6:17 AM

Tevaganthan said:

Thanks a lot."Add the IE7 META tag to the project" method is solved my menu problem on IE8 browser.

# September 11, 2009 5:57 PM

pretty-tiffany said:

Thanks a lot,you can come to my site:

http://www.happytiffany.com

# September 17, 2009 4:36 AM

happytiffany said:

I have read it,thanks

and welcome to my site:

<a href="http://www.pretty-tiffany.com/">http://www.pretty-tiffany.com</a>

# September 17, 2009 4:39 AM

Des Buckley said:

Thank you so much. White space now banished thanks to your z-index patch.

I can get on with life...

# September 18, 2009 3:52 AM

luucy said:

One is always on a strange road, watching strange scenery and listeningto strange music. Then one day, you will find that the things you tryhard to forget are already gone.    http://www.hottiffanyshop.com/Tiffany/tiffany-1837.html

# September 23, 2009 1:55 AM

rob said:

i tried the z index style fix but still no change in IE8..i use the asp menu in a master page,..what should be checked?

# September 24, 2009 10:08 PM

Salvo Rapisarda said:

Wow!

I Just apply "z-index: 100;" in CSS file. Now working good.

Good solution! I like it!!!

In Italian: Grandeeeee!!! ^_^

# September 25, 2009 9:11 AM

Zorro said:

Man, you saved my ass. This was really such an awesome solution.

# September 29, 2009 11:54 AM

Howard said:

I agree with Selvaganapathy.

The z-order fix makes some sense

and works like a charm!

# October 16, 2009 7:09 AM

vidigo said:

Thank you. Solution 2 works perfect.

# October 21, 2009 2:26 AM

Sebastián said:

Thanks a lot. I used a combination of the solutions 1 and 3. 1 for fix ASP Menu and 3 for hide compability view button at IE8.

# October 25, 2009 10:16 AM

Pakaraima said:

Thanks for this fix. This problem is still posted as an outstanding problem on other sites. I stumbled on this site when it was obvious that Firefox and Chrome did not exhibit similar symptoms. After that I was able to formulate a query that pointed me to this site.

# October 30, 2009 10:30 AM

gummadi sri ramulu said:

i tried the same way what you suggested but when i done the 3rd step ie adding CSSFriendlyAdapters.browser

it is giving error

so please suggest me for further to rectify that fix

thanks for your suggestion

# November 4, 2009 12:15 AM

incilay said:

Thank you for solution. My problem is solved.

# November 4, 2009 4:43 AM

Mr. D said:

gr8! It fixed up my issue. Thank u for the solution.

# November 4, 2009 6:57 PM

Shavkat said:

Thanks a lot, very helpful! The IE7 META tag worked for me, although overriding z-index property didn't work for some reasons.  

# November 5, 2009 1:53 AM

Jesse L said:

Thank you! z-index worked perfectly.

# November 19, 2009 1:35 PM

Venkat said:

This method Useful for my project. But this same problem Occur when I use Mozilla Firefox3.5.1 browser . Can u tell me any Solution?

# November 30, 2009 11:53 PM

NinjaCross said:

The trick works like a charm, thanks !

# December 3, 2009 12:02 PM

Davide said:

Proprio la soluzione che cercavo da settimane.

Neanche su asp.net c'era una soluzione.

Ma se è un comportamento normale, come mai VWD2008 non lo risolve automaticamente?

La soluzione n° 1 ha funzionato dappertutto, oltretutto essendo menu in default.master, con una modifica si risolve per l'intero portale.

Ciao

grazie Giorgio.

Just the solution I was searching for!

asp.net doesn't propose any solution to this issue.

However, if this functionality is normal, why VWD2008 doesn't solve the problem by itself?

Solution n 1 worked everywhere, and because menu are on default.master, one modify solve the problem of the web site.

Bye

Thanks Giorgio.

# December 16, 2009 9:34 AM

srinu said:

hi nice solution,i got solution to my problem to follow

second technique (Add the IE7 META tag to the project)..

thanks a lot

regards

srinu ganaparthi

# December 17, 2009 9:10 PM

saif ur rehman said:

thanks,

we are facing this problem for the last many days,

but this article help me very much to solve the

problem..

bundle of thanks............

saif (Islamabad, Pakistan )

# December 25, 2009 10:08 PM

Mobile phone said:

Thank you! z-index worked perfectly.

# January 12, 2010 6:25 PM

Yisman said:

Thanks a million!

first hack worked just dandy!!!

# January 13, 2010 3:02 AM

JimDandy said:

Hi,

I found this article very helpful for rendering the control menus in IE8 but now I have DIV problems rendering the browser in IE7 compatibility mode. The Divs become mis aligned and are out of sync. For instance an image is moved to the next div.

Any Ideas?

Thanks

Jim

# January 18, 2010 12:47 PM

Julie said:

Thank you Giorgio Sardo, for coming up with this solution. Really appreciate your efforts.

  The menu finally worked with the 2 solutions!

# January 20, 2010 5:25 AM

Nina said:

Thank you for this solution - workaround 1 solved my problem in IE8.

# January 27, 2010 1:38 AM

orcor81 said:

Me saco el sombrero, muchas gracias!!!

# February 3, 2010 8:34 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker