You are here: Rants, Rave, & Tips

Rants, Raves & Tips

asp:Menu Flicker on Page_Load - Solved

Date: 7/13/2015 1:48:00 PM

Have an asp:menu that is flickering on (showing all the sub menus) on page_load and/or post back?  Of course you do, because that server control is pretty squirrely.   Here's the simple CSS fix that corrects the issue:

<style type="text/css">
/* fixes ugly menu flicker */
.menu ul li ul { display: none; }
.menu ul li { position: relative;  float: left; list-style: none; }
.menu ul li ul li { width: 100%; }

I've seen numerous "fixes" for Css menu getting flickering while page post back, but the ones I found never included the 3rd line.  If you have sub menus, the 3rd line (.menu ul li ul li) corrects the width and positioning issue.

Cheers and happy coding!