views:

586

answers:

1

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? :(

+1  A: 

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.

Zhaph - Ben Duguid
This is working very well indeed, the ScriptManager.AsyncPostBackSourceElementID property wich is returning a UniqueID,and you can use the FindControl to figure from where the asyncpostback was triggered.Thanks for the solution!
Sad0w1nL1ght
Huzzah! Glad to help.
Zhaph - Ben Duguid