在母版页上使用时,ASP.Net菜单控件呈现不正确 [英] ASP.Net Menu Control renders incorrectly when used on a Master Page

查看:77
本文介绍了在母版页上使用时,ASP.Net菜单控件呈现不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当与母版页一起使用时,我正在努力寻找针对ASP.Net菜单控件的怪异问题的解决方案.

I'm struggling to find a solution for a weird issue with ASP.Net Menu control, when used in conjunction with Master Pages.

当用户导航到页面时-通过.菜单-从母版页继承,整个菜单会展开并在屏幕上闪烁.立即折叠并呈现页面. 在屏幕上引起一些闪烁,使用户感到烦恼.

When the user navigates to a page - via. the menu - which inherits from the Master Page, the entire menu just expands and flashes across the screen. Collapses immediately and the page is rendered.... Causes some flickering on the screen, annoying for the users.

现在,为此提出了一些解决方法: -从web.config中注释掉标签. -在其Page_Load事件中为母版页提供ID. 都试过了,似乎并没有解决我的问题:(. 我会考虑的.

Now, there are a few work-arounds suggested for this: - Commenting out the tag from the web.config. - giving IDs to the Master Pages in their Page_Load events. Tried'em all, dosen't seem to sort out my issue :(. I'd take any ideas.

-香港

推荐答案

我记得在我的某个地点看到过这一点.从那以后,我将菜单翻录了下来,但是将其放回到我的母版页中,我再也看不到闪烁了.这是一个简单菜单的代码,该菜单在母版页中不会闪烁;

I remember seeing that at one point in a site of mine. Since then I ripped the menu out, but putting it back into my master page I don't see the flicker any more. Here's the code for a simple menu that works without flicker in a master page;

<asp:Menu ID="menu" 
    DataSourceID="sitemap" 
    runat="server" />
<asp:SiteMapDataSource 
    ID="sitemap" 
    ShowStartingNode="false" 
    runat="server" />

我自己没有尝试过,但是如何将菜单子级的默认类设置为不可见(例如,invisibleMenu类),这意味着它最初是不可见的加载,然后使用一些JavaScript来删除不可见性?在jQuery中,类似

Not tried it myself, but how about setting the default class for the menu children to invisible (say, a class of invisibleMenu), which means it initially loads invisibly, and then using a bit of javascript to remove the invisibility? In jQuery, something like

$('.invisibleMenu').removeClass('invisibleMenu');

这篇关于在母版页上使用时,ASP.Net菜单控件呈现不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆