ASP:菜单停止工作不同的控制部分执行AJAX回发后 [英] asp:Menu stops working after a different control performs partial AJAX postback

查看:85
本文介绍了ASP:菜单停止工作不同的控制部分执行AJAX回发后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出现此问题在ASP.NET 4.6和我已经看到了一些类似的职位,但他们通常不是指同一控制(内置这里)或结束了一个结论只是用不同的/外部控​​制在这里:HTML链接,这是不是一个真正的选择,我

This issue occurs in ASP.NET 4.6 and I've seen a few similar posts, but they usually referred not to the same control (built-in here) or ended up with a conclusion "just use a different/external control here: html link", which is not really an option for me.

的Site.Master

Site.Master

 <div id="HeaderProper">
    <div id="HeaderProperTitle">
        <asp:Menu ID="HeaderProperMenu" runat="server" DataSourceID="HeaderProperSiteMap" Orientation="Horizontal"  
            BackColor="#ff2400" 
            RenderingMode="List"
            StaticEnableDefaultPopOutImage="false"
            StaticDisplayLevels="2"
            StaticHoverStyle-BackColor="#000000"
            StaticMenuItemStyle-HorizontalPadding="15px"
            StaticMenuItemStyle-Height="42px"
            DynamicHoverStyle-BackColor="#000000" 
            DynamicMenuItemStyle-HorizontalPadding="5px"
            DynamicMenuItemStyle-BackColor="#ff2400"
            DynamicMenuItemStyle-Font-Size="24px"/>
<asp:SiteMapDataSource ID="HeaderProperSiteMap" runat="server" />
</div>

SomePage.aspx页面

SomePage.aspx

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>Complete List</h1>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div class="SortOrderSelection">
                    Sort by
                    <asp:DropDownList ID="cbxSortBy" runat="server" AutoPostBack="true"
                        OnSelectedIndexChanged="cbxSortBy_SelectedIndexChanged" />
                </div>
                <asp:Panel ID="SortedList" CssClass="top-margin five-columns" runat="server" />
                <asp:Panel ID="Summary" CssClass="top-margin" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>

如何重现:
选择在DropDownList,这会导致局部回传的项目。然后菜单停止工作,那就是 - 下拉/悬停菜单不开,但一级链接似乎功能。刷新整个页面修复问题(废话?)。

How to reproduce: Choose an item in the DropDownList, which causes partial postback. The menu then stops working, that is - the drop down/hover menu doesn't open, but the first level links seem to be functional. Refreshing the whole page fixes the problems (duh?).

和,相反的是我发现:
1)菜单是不是一个UpdatePanel,这我承认里面是不支持的解决方案
2)当的renderingMode设置为表菜单工作得很好,但会产生一个非常难看的HTML code,这是我想避免的。在必须与丑陋的修复调整页边距不提额外的怪癖。
3)我尝试设置的z-index:1000 ... 0重要的一些消息人士的建议(在大多数菜单相关的款式),但无济于事。

And, contrary to what I've found: 1) Menu is NOT inside an UpdatePanel, which I acknowledge is unsupported solution 2) Menu works fine when RenderingMode is set to Table, but generates a very ugly html code, which I would like to avoid. Not mentioning additional quirks in margins that have to be adjusted with ugly fixes. 3) I tried setting z-index: 1000...0 !important as suggested by some sources (on most menu related styles), but to no avail.

而仍然使用ASP我会的任何建议感激这可怎么解决。在这里我想说的是使用内置功能,并保持code干净不必要的JS,jQuery的(如果有可能的话,否则我宁愿开连接的​​情况下这个问题)。
谢谢你在前进。

I would be grateful for any suggestions how this can be resolved while still using asp:Menu control in List rendering mode, possibly with as least intervention as possible. My point here is to use built-in functionality and keep the code clean from unnecessary JS, jQuery (if possible at all; otherwise I'd rather open a Connect case for this issue). Thank you in advance.

推荐答案

把你的菜单到一个更新面板应工作,因为它会显示到服务器的回发后进行更新。没有这一点,任何转贴可以创建你的元素失去一些事件的风险。令人耳目一新的作品,因为你是刷新整个页面,而不仅仅是它的一些元素。

Putting your menu into an update panel should work because it will indicate to the server to update it after the postback. Without this, any repost can create the risk of losing some events in your element. Refreshing works because you are refreshing the whole page and not only some element of it.

这篇关于ASP:菜单停止工作不同的控制部分执行AJAX回发后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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