【问题标题】:ASP.NET AJAX UpdatePanels Will Not Detect Other UpdatePanel ChangesASP.NET AJAX UpdatePanel 不会检测到其他 UpdatePanel 更改
【发布时间】:2013-05-10 14:47:20
【问题描述】:

我在一个网页上有两个更新面板。它们都设置为 UpdateMode="Conditional"。它们不是嵌套的。我的问题是,当我希望 UpdatePanelOne 上的控件更新 UpdatePanelTwo 上的控件时,两个控件将永远不会更新。我不想将 UpdateMode 设置为 always。如何让 UpdatePanelTwo 反映 UpdatePanelOne 上发生的更改?

【问题讨论】:

    标签: asp.net ajax updatepanel


    【解决方案1】:

    好吧,我不是 100% 认为这是您正在寻找的,但使用触发器可能就是答案:

    例如

    以网络形式:

      <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
                <ContentTemplate>
    
                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                </ContentTemplate>
    
            </asp:UpdatePanel>
            <br /><br />
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
    
                <ContentTemplate>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
        </form>
    

    在代码隐藏中:

    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "YO";
    }
    

    在第一个更新面板中单击 Button1 会触发第二个更新面板中 Label1 的 Text 属性的更新。

    【讨论】:

    • 就是这样。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-25
    • 2010-12-29
    • 2012-12-05
    • 1970-01-01
    • 2010-09-14
    • 2011-03-25
    • 2011-02-02
    相关资源
    最近更新 更多