我只是有这个同样的问题。在同一页面上的两个更新面板不嵌套并且具有UpdateMode =“有条件”。只要认识到,当页面上的一个更新面板触发部分回发时,所有更新面板都将触发更新事件。如果你迷上了UpdatePanel的A中的UpdatePanelAnimationExtender和部分回发触发无关的UpdatePanel B,都将得到更新事件触发,并为UpdatePanel的一个动画将只运行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();
我希望这可以帮助别人。
更新面板如何相互关联?那是一个嵌套在另一个里面吗?什么是ChildrenAsTriggers设置在每个设置? – drs9222 2009-07-24 23:17:24