在 Asp.Net AJAX 的嵌套 UpdatePanel 中的 AsyncPostbacks 之间有所不同 [英] Making a difference between AsyncPostbacks in nested UpdatePanels in Asp.Net AJAX

查看:25
本文介绍了在 Asp.Net AJAX 的嵌套 UpdatePanel 中的 AsyncPostbacks 之间有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 ASP.net AJAX 项目 (WebForms) 中,我有一个 UpdatePanel,在 UpdatePanel 中我有多个带有 UpdatePanel 的嵌套控件,基本上我有控件树.

In an ASP.net AJAX project (WebForms), I have an UpdatePanel, and in UpdatePanel I have multiple nested Controls with UpdatePanels, basically I have control trees.

家长控制是网站的巨大且非常重要的部分.我不能触摸它,(而且它在很多地方被重复使用),UpdatePanel 应该保持在它的当前位置.

The Parent Control is huge and very important part of the site. I cannot touch it, (and also it is reused on many places), the UpdatePanel should remain in its current position.

更新面板中的子控件具有相互分离的功能(它们也与 UpdatePanel 分离),以便能够仅刷新控件中的一部分.

The child controls in the update panel have functionality's which are separated from each other(also they are separated with UpdatePanel), to be able to refresh just a piece from a control.

基本上在 Page_Load() 上,我的代码可以用数据实现每个子控件,例如,如果我有一个删除功能,它正在修改子控件数据.步骤如下:

Basically on Page_Load() I have code which fulfills every Child control with data, for instance if I have a delete functionality which is modifying the child controls data. The steps are like this:

首先显示控件(ParentControl).

First showing the control (ParentControl).

  • Page_Load() ->填写数据

如果我点击删除:

  • Page_Load() ->fullfill data/* 不想在这里调用它!*/

  • Page_Load() -> fullfill data   /* Don't want do invoke this here! */

事件删除 -> 修改数据

event Delete ->modify data

       ->fullfill data again!

我需要对 AsyncPostbacks 进行编程上的改动,并使用 Page_Load() 函数在您只想执行事件时不调用完成数据.

I need to make a programmatical difference on AsyncPostbacks,and use on Page_Load() function to not invoke the fulfill data when you just want to perform an event.

在 UpdatePanel 之外,您可以使用 IsAsyncPostbackIsCallBackIsPostback 我肯定知道,但这些 属性不会改变在 AsyncPostback 上.

Outside UpdatePanel you can use IsAsyncPostback,IsCallBack,IsPostback I know this for sure, but these properties don't change on AsyncPostback.

我有 2 个 AsycPostbacks,我需要区分它们.:

I have 2 AsycPostbacks and I need to make differentiate between them.:

  1. 首先这只是显示数据和初始化.
  2. 执行事件并对控件进行修改

有人知道一种实现技术,或者某种具有这种功能的框架吗?

Have somebody know a technique to implement, or some sort of Framework which is having this type of functionality?

有人有这个问题吗?

推荐答案

我已经删除了我的另一个答案 - 看到你现在描述的问题与最初的问题完全不同,完全替换我的答案似乎很愚蠢,同时保留以前版本的代表.

I've deleted my other answer - seeing as you're now describing a completely different problem to the initial one, and it seemed foolish to completely replace my answer, while keeping the rep for the previous version.

您将不得不检查导致异步回调的事件,或者检查每个更新面板中控件的某些值,以帮助您找出更改的内容.

You're going to have to check either the events causing the asynchronous call backs, or check for some value of the controls in each of the update panels to help you work out what's changed.

这是我决定不使用更新面板的关键原因之一,异步回发导致几乎所有页面生命周期事件发生,并且很难真正看到在复杂情况下发生了什么,例如这 - 我唯一一次愤怒地使用更新面板是在我的个人网站上环绕数据网格以在处理大量数据时保存整个页面重新加载.

This is one of the key reasons I decided not to use update panels, the asynchronous post-back causes almost all of the page life-cycle events to happen, and makes it very hard to actually see what's happening in complex situations like this - the only time I've used an update panel in anger was on my personal site to wrap around a data grid to save the whole page reload when working with large sets of data.

编辑添加:

只是想帮忙,一个快速的谷歌出现了 this(AJAX 和 ASP.NET 2.0 回调框架):

Just trying to help, a quick google turned up this (AJAX and the ASP.NET 2.0 Callback Framework):

哪个控件发起了请求?

在回发请求中,ScriptManager id 作为参数进行操作.通常,该值是启动部分回发的控件的 id.它的格式为 |.控件可以直接或通过 UpdatePanel 向 ScriptManager 注册.ScriptManager.AsyncPostBackSourceElementID 属性将返回发起部分回发的控件的 ID.

In the postback request, the ScriptManager id operates as the parameter. In general, the value is the id of the control that initiated the partial postback. It is in the format |. Controls can register with the ScriptManager directly or via an UpdatePanel. The ScriptManager.AsyncPostBackSourceElementID property will return the id of the control that initiated the partial postback.

示例语法:

ScriptManager1=UpdatePanel1|Button1

该页面还详细介绍了生命周期以及流程中的各种挂钩.

That page also goes into some detail about the life cycle, and various hooks into the process.

这篇关于在 Asp.Net AJAX 的嵌套 UpdatePanel 中的 AsyncPostbacks 之间有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆