I thought I should share this, as I have not come across much about it in any of the forums.
I have been using ajax update panels extensively, but have often been disappointed with their performance when used in pages that loads controls dynamically. In my case, I had several dynamic controls placed in the master page that themselves relied on ajax functionality. On regular postbacks, these controls need to be regenerated during the PageInit phase, so the option to wrap the initialization in a if not page.ispostback is not really there to prevent the code from running when it is not supposed to. The implication is a great deal of additional useless work on the server during async postbacks.
During an asynch postback would most of these controls not have to be re-initiated at all. By wrapping the PageInit/PageLoad routine in the following construct, I can achieve the same effect as with the page.ispostback construct:
If
Not ScriptManager.GetCurrent(Me.Page).IsInAsyncPostBack Then
End If
In case the control implements ajax itself, I use this construct:
Dim sm As ScriptManager = ScriptManager.GetCurrent(Me.Page)
If sm.IsInAsyncPostBack Then
If sm.AsyncPostBackSourceElementID.IndexOf("YourWebControlClassName") > -1 Then
...initialization code to run if the async postback was initiated by any child control on the web control.....
End If
End If
I find this to work well - speeding up my apps significantly, but might there be any reason not to do it, or is there perhaps a better way that I might have missed?