【问题标题】:Why updatepanel triggers another updatepanel?为什么 updatepanel 会触发另一个 updatepanel?
【发布时间】:2010-05-30 20:22:04
【问题描述】:

我的 ajax 页面上有两个更新面板。这是我第一次使用 updatepanel,我不知道出了什么问题。我认为只有 btnFilter 的 Click 事件必须触发第二个更新面板的内容,但更改组合值(也隐藏/取消隐藏 btnFilter 按钮)会使第二个 updatepanel 更改内容(至少我看到传输的数据与 firebug 和第二个 updatepanel 有时会闪烁)。在线here

<asp:UpdatePanel ID="upComparison" runat="server">
    <ContentTemplate>
        Brand:
        <asp:DropDownList ID="ddlBrands" runat="server" AutoPostBack="true"
        OnSelectedIndexChanged="ddlBrands_SelectedIndexChanged"
        AppendDataBoundItems="true">
            <asp:ListItem Value="" Text="Please select a brand..." />
        </asp:DropDownList>
        <asp:Panel ID="pModels" runat="server" Visible="false">
            Model:
            <asp:DropDownList ID="ddlModels" runat="server" AutoPostBack="true"
            OnSelectedIndexChanged="ddlModels_SelectedIndexChanged" />
        </asp:Panel>
        <asp:Panel ID="pButton" runat="server" Visible="false">
            <asp:UpdateProgress ID="upMain" runat="server" DisplayAfter="100">
                <ProgressTemplate><img src="/Assets/Images/loader.gif" />
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:Button ID="btnFilter" runat="server" Text="Filter" 
            OnClick="btnFilter_Click" />
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>    
<asp:UpdatePanel ID="upList" runat="server">
    <ContentTemplate>
        <asp:Repeater ID="rProducts" runat="server">
            <ItemTemplate>some code here</ItemTemplate>
        </asp:Repeater>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

【问题讨论】:

    标签: c# asp.net ajax asp.net-ajax


    【解决方案1】:

    默认情况下,每个UpdatePanel 都会在每次异步回发期间刷新。

    要更改此行为,请将UpdateMode property 设置为Conditional

    【讨论】:

    • +1,我想知道为什么它默认设置为Always。必须与 EnableViewState 后面的延迟相同,默认为 true...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-12
    • 2011-12-16
    相关资源
    最近更新 更多