Geeks With Blogs

News
Steve Clements .Net and then some....

Hi There

If like me you love to use CSS instead of HTML tables for the layout design of your pages then you no doubt have at least tried the CSS Adapter for asp.net 2.0 controls, if not take a look here.

Scott Gu has a great blog on it here, which discusses the new release, how to install etc. In a previous post (link to it on the same post) he talks about how easy it is to write your own adapter.

It comes with a nice tutorial and sample application, I have to say that its not as straight forward as I originally thought but once you get your head round the extensive (to me!) CSS classes you'll love it....not to mention the huge reduction in page size (in my case anyway ;-D).

 

So anyway..the error!!!

IE6 doesn't support the :hover tag in CSS on anything other than 'a' tag, so the adapter uses JavaScript to perform the action.....it runs a function that attaches to the onmouseover and onmouseout event, the function is run like this

window.onload = SetHover_AspNetMenu;

...well if in your own page you override the onload event like this..

this.onload = function() {
    //some code in here
}

then the SetHover.. function will not be called.  First of all I simple did a check for < IE7 and ran the code myself from my own onload override.  Then after talking with Russ on the asp.net forums he suggested coming up with a simple way to do this for everyone.  So I added this to bottom of the MenuAdapter.js file

function SetupMenuForIE6() {
      if (isPreIE7) {
            SetHover__AspNetMenu();
     }
}

Then went into the MenuAdapter file where all the other scripts are called in the method RegisterScripts() and added this   

Page.ClientScript.RegisterStartupScript(GetType(), "Menu-IE6-JS",
               "<script type='text/javascript'>SetupMenuForIE6();</script>");

Hope this helps someone has had the same problem I have.

Steve

Posted on Wednesday, September 13, 2006 2:06 PM | Back to top


Comments on this post: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6

# re: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6
Requesting Gravatar...
I think you should try the IE7 patch by Dean Edwards, it makes possible to use hover on other tags than 'a', and works on IE6.
Left by Szokelizer on Sep 14, 2006 7:24 AM

# re: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6
Requesting Gravatar...
Hi,

I didn't quite understand what was the problem you were facing. So I have installed beta2.0 of friendly CSS adapters, so I have bug in it?

Which needs to be fixed? Or you just wanted some additional feature to work?

thank you for possible further explanation...

P.S. if it is bug, does MS knows about it? or we should look for some mentioned patch by Dean Edwards?
Left by kassad on Sep 20, 2006 11:20 AM

# re: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6
Requesting Gravatar...
MS do know about it yes...well the guy who wrote is for MS knows(Russ Hefland).
The problem is that the CSS adapter overrides the javascript onload event on the page...so if you also have an override method for the event the CSS one will then be overridden by yours...and so the hover events handlers will not be attached to the li element.

So if you alter the adapter code as above (which i have been through with Russ) then the problem is solved....there is possibly a better way to attach the event but this is quick and easy and worked for me.

Hope this helps.
Left by Steve on Sep 20, 2006 2:20 PM

# re: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6
Requesting Gravatar...
You should probably know that this website, or at least this page, causes IE7 under XP SP2 to lock up HARD, going into a 100% CPU usage loop and “(not responding)”, requiring an End Task / End Process from Task Manager.

I had to resort to Firefox just to get this far!
Left by COMALite J on Jan 11, 2008 1:54 AM

# re: CSS Adapter for ASP.net 2.0 - Mouseover not working in IE6
Requesting Gravatar...
I was stuck in this for a day and wondered why it worked in firefox and not ie6, thought it was problem in my code!
Thanks for the solution.

Cheers
Left by Prash on Sep 07, 2009 5:52 AM

Your comment:
 (will show your gravatar)


Copyright © Steve Clements | Powered by: GeeksWithBlogs.net