gpt4 book ai didi

asp.net - 如果子更新面板的子控件都设置为有条件,为什么子控件会同时更新父控件和子控件?

转载 作者:行者123 更新时间:2023-12-02 17:21:27 24 4
gpt4 key购买 nike

我们有一个包含 3 个主要 UpdatePanel 的结构,每个 UpdatePanel 都有多个嵌套的 UpdatePanel(但只有一层嵌套)。所有面板都设置为有条件的,ChildrenAsTriggers 设置为 false,因此它看起来大致如下:

<asp:UpdatePanel ChildrenAsTriggers="false" OnLoad="Update_OnLoad" 
ID="updateCol2" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:UpdatePanel ChildrenAsTriggers="false" UpdateMode="Conditional"
ID="updateFeed" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button OnClick="function" ID="btnSubmit" runat="server" />
<ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

我希望父更新面板的 OnLoad 函数除了在实际页面加载时永远不会运行,并且按钮的 OnClick 函数将在每次单击时执行,从而更新子更新面板。但是,每次单击按钮时父 UpdatePanel 都会更新,并且子更新面板仅在之后触发(作为父 UpdatePanel 更新的结果。)

最佳答案

父更新面板是否实际更新,即内容正在更改?

I would expect that the OnLoad function of the parent update panel would never run except on the actual page load

这是一个错误的假设,但不幸的是这是常见的假设。请记住,即使它是异步回发,也会为每个控件执行整个页面和控件生命周期,包括 Load 和 Init。就像您正常请求该页面一样。

不同之处在于,仅更新页面的 UpdatePanel 区域,而不是整个 UI。

有关 UpdatePanel 如何工作的更多信息,请访问 great article on ASP.Net Ajax documentation site .

关于asp.net - 如果子更新面板的子控件都设置为有条件,为什么子控件会同时更新父控件和子控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1178472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com