Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of ugly asp:Menu flickering?

I'm using the asp:Menu control on an ASP.NET 4.0 Webforms page with table-free rendering mode:

<asp:Menu ID="MenuBase" runat="server" DataSourceID="SiteMapDataSourceMenu"
    Orientation="Horizontal" CssClass="contentmenu" RenderingMode="List" 
    IncludeStyleBlock="false">
</asp:Menu>

The menu has a horizontal main row with 5 or 6 menu items and some of them open vertical popup menus when the user hovers over them.

Often when any postback occurs and the page gets rendered again the menu "flickers" for a moment (say, half a second) which means: All menu items - including the items in the popup menus - are displayed in one or more rows one after each other before they return to the normal intended state.

In this short moment of an "unfolded" display of all menu items the menu looks AS IF Javascript had been disabled in the browser. (It seems that building the popup menus is achieved by using some Javascript in the asp:menu control.)

This behaviour is quite ugly, especially with a big menu (rendering for the short moment over 2 or 3 rows) the whole page content is moved down before it jumps back to normal display.

Do you know any solution for this problem?

Thank you in advance!

(Remark: I should mention that I used the well-known CSS-friendly menu control from CodePlex before I upgraded to ASP.NET 4.0. I supposed that I don't need the CSS-friendly control anymore because the asp:Menu in version 4 offers a built-in List rendering mode now. As far as I remember I didn't have this flickering with the CSS-friendly control and I think this control does not make use of Javascript. Perhaps this was a bad step. I am looking now for a solution without going back to the CSS-friendly menu control, if possible.)

Edit:

This flickering is browser independent, although most noticeable in IE 8 and 7. In IE 7 (or Compatibility mode in IE 8) it's extraordinary ugly since the menu items get displayed in a crazy diagonal pattern even over 5 or 6 rows.

like image 334
Slauma Avatar asked Jul 13 '10 19:07

Slauma


People also ask

How do I stop page flickering in asp net?

One thing you can do to minimize flicker is to create a default page which has all the default elements you need, and add a placeholder for page-specific content. Next, you can replace the content of the placeholder with the specific content for the page you're loading.

How do I stop angular flickering?

The ngCloak directive is used to prevent the AngularJS html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

Why does my page flicker?

Web pages loads slowly and gives a white flicker because many a times the browser is tied up with processing the components in the page as : images, style sheets, scripts, Flash etc. Before rendering any page, browsers will always wait until everything (beyond images) has finished downloading.

How do I stop Google Play from flickering?

the screen flickering issue in the certain google apps is a known issue, while we are waiting on a fix from google the temporary solution to resolve the issue is to uninstall the updates of the Android System WebView in the Playstore or Settings.


2 Answers

If anyone still needs a solution; the flickering is there because you should set the correct display style in your css for the menu.

Try for example

#menu ul li ul
{
    display: none;
}

and

#menu ul li 
{
    position: relative; 
    float: left;
    list-style: none;
}

The flickering is because the ASP.NET 4 menu uses javascript to set some inline styles.

like image 129
peter Avatar answered Sep 30 '22 04:09

peter


I also picked up this problem whenever I had a lot going on in the page between the CSS file and the onload event which presumably triggers the javascript to decorate the menu items. Particularly in IE8 this delay for javascript to fix the styling was ugly.

The solutions from peter and Clearcloud8 were almost good for me. I use this:

div.menu > ul > li
{ 
    display: inline-block;
    list-style: none; 
} 

div.menu ul li ul 
{ 
    display: none; 
}

The main difference being that I used "div.menu > ul > li" which targets only the topmost row of items, instead of "div.menu ul li" which afects the sub-menus also - the result being that the submenu items were not the same width, so they dropped down in a jagged list.

(I am using Visual Studio 2010, .Net Framework 4)

like image 45
Etherman Avatar answered Sep 30 '22 03:09

Etherman