一个更新面板更新了,另一个也更新了?

发布于 2024-07-29 16:35:02 字数 888 浏览 7 评论 0原文

我有一个场景,页面上有两个更新面板(都有更新模式=“条件”)。 如果我更新一个更新面板,另一个更新面板也会自动更新。 这是第一个问题。

我正在使用UpdatePanelAnimationExtender。 如果一个更新面板已更新,则该面板没有 updatepanelAnimationExtender,而另一面板也已更新且具有 updatepanelAnimationExtender、OnUpdatingUpdatePanel(); 事件被触发。 正如 updatepanelAnimationExtender 的文档所述: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ UpdatePanelAnimation/UpdatePanelAnimation.aspx

OnUpdating - 当任何 UpdatePanel 开始更新时播放的通用动画

OnUpdated - 在 UpdatePanel 之后播放的通用动画>UpdatePanel 已完成更新(但前提是 UpdatePanel 已更改)

问题: OnUpdating 已触发并且它在后端运行但未完成因为 onUpdated 仅在 UpdatePanel 更改时触发

I have scenario, I have two update panels on the page (both have update mode='conditional'). If I update one update panel the other is automatically updated. This is first problem.

I am using UpdatePanelAnimationExtender. If one update panel is updated, that don’t have updatepanelAnimationExtender other one also updated and that have updatepanelAnimationExtender, OnUpdatingUpdatePanel(); event is fired.
As the documentation of updatepanelAnimationExtender says:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/UpdatePanelAnimation/UpdatePanelAnimation.aspx

OnUpdating - Generic animation played as when any UpdatePanel begins updating

OnUpdated - Generic animation played after the UpdatePanel has finished updating (but only if the UpdatePanel was changed)

Problem: OnUpdating fired and it worked backend and not finished because onUpdated only fired when an UpdatePanel Changed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小糖芽 2024-08-05 16:35:02

“在页面上添加 2 个更新面板,为两个更新面板设置 updatemode='conditional',为两个更新面板添加加载事件,为两个加载事件设置断点,添加 1 个按钮,然后为按钮单击 1 个更新面板添加 Asyn 触发器......您会注意到,当您点击按钮时,它应该仅加载触发的更新面板,并且第二个更新面板保持不变,但第二个更新面板也触发了加载事件“

只有当按钮位于第二个更新面板内时才会发生这种情况? 如果没有,那么我认为它不会更新第二个更新面板。 您能否确认该按钮是在第二个更新面板内部还是外部?

"Add 2 update panel on page, set updatemode='conditional' for both and add load event for both updatepanel and set breakpoint for both load event and add 1 button and then add Asyn trigger for button click on 1 update panel.... you will notice when you hit button, it should load only triggered update panel and 2nd one remain unchanged, but 2nd updatepanel is load event also fired"

This will happen only if the button is inside the 2'nd updatepanel? If not, then I dont think it will update the second update panel. Could you confirm if the button is inside or outside the second updatepanel?

再浓的妆也掩不了殇 2024-08-05 16:35:02

我刚刚遇到了同样的问题。 同一页面上的两个更新面板不嵌套且具有 UpdateMode="Conditional"。 只需要意识到,当页面上的一个更新面板触发部分回发时,所有更新面板都会触发更新事件。 如果您将 UpdatePanelAnimationExtender 连接到 UpdatePanel A,并且为不相关的 UpdatePanel B 触发了部分回发,则两者都会触发更新事件,并且 UpdatePanel A 的动画将仅运行 OnUpdating 部分,而不运行 OnUpdated 部分(因此基本上动画会运行一半)。

这就是我解决这个问题的方法:
确定触发了哪个更新面板。 这可以通过获取脚本管理器的表单变量的值来找到。 有问题的更新面板将在字符串中提及。 使用此信息根据您的需求执行操作。

// Variable to hold ScriptManager.  Just slap this in the class for the page.
private ScriptManager scriptManager;

// Get the ScriptManager.  Put this in Page_Init handler.
// If you have the ScriptManager on the same page, just refer to it directly.
// If you have it on the master page, you can get a reference to it like so.
// The second line shows one way you can get a reference to the ScriptManager from
// a user control.
// FYI, the same code applies to a ToolkitScriptManager.
scriptManager = ScriptManager.GetCurrent(this);
// scriptManager = ScriptManager.GetCurrent(HttpContext.Current.Handler as Page);

// This function checks whether an UpdatePanel is being updated
private Boolean IsUpdatePanelUpdating(String sUPID)
{
    String sUpdateValue = Request.Form[Request.Form.AllKeys.Where(s => s.EndsWith(scriptManager.ClientID)).FirstOrDefault()] ?? String.Empty;
    return sUpdateValue.Contains(sUPID);
}

// This is code you can put somewhere (say within OnLoad handler) to make an
// UpdatePanel A get updated even if an unrelated UpdatePanel B is currently being
// updated.
if (!IsUpdatePanelUpdating(upA.ClientID))
    upA.Update(); 

我希望这可以帮助别人。

I just had this same issue. Two update panels on the same page that are NOT nested and have UpdateMode="Conditional". Just realize that when one update panel on a page triggers a partial postback, all update panels will get the updating event triggered. If you have an UpdatePanelAnimationExtender hooked up to UpdatePanel A, and a partial postback is triggered for an unrelated UpdatePanel B, both will get the updating event triggered, and the animation for UpdatePanel A will only run the OnUpdating part and not the OnUpdated part (so basically the animation will run half way).

This is how I fixed this issue:
Determine which update panel was triggered. This can be found by getting the value of the form variable for the script manager. The update panel in question will be mentioned in the string. Use this info to perform an action based on your needs.

// Variable to hold ScriptManager.  Just slap this in the class for the page.
private ScriptManager scriptManager;

// Get the ScriptManager.  Put this in Page_Init handler.
// If you have the ScriptManager on the same page, just refer to it directly.
// If you have it on the master page, you can get a reference to it like so.
// The second line shows one way you can get a reference to the ScriptManager from
// a user control.
// FYI, the same code applies to a ToolkitScriptManager.
scriptManager = ScriptManager.GetCurrent(this);
// scriptManager = ScriptManager.GetCurrent(HttpContext.Current.Handler as Page);

// This function checks whether an UpdatePanel is being updated
private Boolean IsUpdatePanelUpdating(String sUPID)
{
    String sUpdateValue = Request.Form[Request.Form.AllKeys.Where(s => s.EndsWith(scriptManager.ClientID)).FirstOrDefault()] ?? String.Empty;
    return sUpdateValue.Contains(sUPID);
}

// This is code you can put somewhere (say within OnLoad handler) to make an
// UpdatePanel A get updated even if an unrelated UpdatePanel B is currently being
// updated.
if (!IsUpdatePanelUpdating(upA.ClientID))
    upA.Update(); 

I hope this helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文