我有一个带有两个更新面板的网络表单:

<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release">
    </asp:ScriptManager>

<p>
    <asp:UpdatePanel ID="upl1" runat="server">
        <ContentTemplate>
            <asp:Button runat="server" ID="btn1" Text="Button1" />
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdatePanel ID="upl2" runat="server">
        <ContentTemplate>
            <asp:Button runat="server" id="btn2" Text="Button2" />
        </ContentTemplate>
    </asp:UpdatePanel>
</p>


如果单击btn1,则会触发upl2以及upl1的加载事件。

我希望只加载upl1,因为这是包含按钮的更新面板。

为什么没有发生这种情况,我该如何实现呢?

最佳答案

在使用“更新面板”时,我经常使用的一种做法是设置属性:

ChildrenAsTriggers="false" UpdateMode="Conditional"

And refresh the Update Panel only when I want:

protected void btn1_Click(object sender, EventArgs e)
{
    // some logic
    // ....
    upl1.Update();
}

尝试应用这些属性,看看是否可以解决您的问题。

关于asp.net - 单击其中一个按钮时,如何防止所有更新面板重新加载?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15024123/

10-12 13:50