制作AsyncPostbacks之间的差异在Asp.Net AJAX嵌套的UpdatePanel嵌套、差异、Asp、AsyncPostbacks

2023-09-11 00:39:42 作者:两天瘦20斤,不靠节食不靠运动,全靠我自己幻想。小编为元气少

在一个ASP.net AJAX项目(的WebForms),我有一个UpdatePanel,并在UpdatePanel中我有多个嵌套的控制与的UpdatePanel,基本上我有控制的树木。 父控件的网站我不能触摸它,(并且也被重新使用在很多地方),在UpdatePanel 768,16保持在当前位置的巨大的,非常重要的部分。

在更新面板的子控件具有功能的至极彼此(也它们之间用的UpdatePanel),以便能够从一个控制刷新只是一块分隔。 基本上在的Page_Load()我有code至极fullfill每一个孩子的控制数据,例如,如果我有一个删除功能至极正在修改的子控件data.The步骤是这样的:

首先表示控制(ParentControl)。

的Page_Load() - > Fullfill数据 页面生命周期 DOMContentLoaded, load, beforeunload, unload解析

如果我点击删除:

的Page_Load() - > fullfill数据   / *不想在这里做调用此! * /

事件删除 - >修改数据

   - >再次fullfill数据!
 

我需要在 AsyncPostbacks programatical差异,并使用的Page_Load()函数没有调用fullfill数据时,你只是想执行一个事件。

之外的UpdatePanel可以使用 IsAsyncPostback IsCallBack 的IsPostBack 我知道这是肯定的,但这些 propertys没有变化在AsyncPostback

我有2 AsycPostbacks,我需要让他们区分。 1.首先,这只是显示数据并进行初始化。 2.执行一个事件并就控制修改

有别人知道的技术来实现,或某种框架至极的是有这种类型的功能?

是否有人有这个问题? :(

解决方案

我已经删除了我的其他回答 - 看你现在描述一个完全不同的问题,最初的一个,它似乎愚蠢的完全替代我的回答,同时保持代表为previous版本。

你将需要检查或者对事件造成的异步回调,或者检查是否控制在每一个更新面板的一些价值,帮助你的工作有什么变化。

这是我决定不使用更新面板的关键原因之一,回来后异步导致几乎所有的页面生命周期事件发生,使得它很难真正看到发生了什么复杂的情况,如这一点 - 我使用的更新面板在愤怒的唯一的一次是在我的个人网站环绕一个数据网格与大型数据集工作时节省整个页面重新加载

编辑补充:

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

  

其中控制发起请求?的

     

在回发请求下,ScriptManager ID用作参数。在一般情况下,该值是发起局部回传控制的id。它在格式|。控制可以使用ScriptManager直接或经由一个UpdatePanel寄存器。该ScriptManager.AsyncPostBackSourceElementID属性将返回发起局部回传控制的ID。

     

示例语法:

  ScriptManager1 = UpdatePanel1 | Button1的
 

这页也进入了一些细节的生命周期,及各种挂钩插入过程。

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. 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 shoud remain on current position.

The child controls in the update panel have functionality's wich are separated from each other(also they are separated with UpdatePanel),to be able to refresh just a piece from a control. Basically on Page_Load() i have code wich fullfill every Child control with data,for instance if i have a delete functionality wich is modifying the child controls data.The steps are like this:

First showing the control (ParentControl).

Page_Load() -> Fullfill data

If i click on delete:

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

event Delete ->modify data

     ->fullfill data again!

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

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

I have 2 AsycPostbacks and i need to make differentiate between them. 1. First this just showing data and initialize. 2. Perform an event and making modifications on control

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

Does anybody has this problem? :(

解决方案

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.

Edit to add:

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

Which control initiated the request?

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.

Example syntax:

ScriptManager1=UpdatePanel1|Button1

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