In a page contains two UpdatePanels
, How can I know which UpdatePanel
causes the partial PostBack
?
I mean in the Page_L
is possible to determine the object inside an update panel an execute the code needed
If (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) Then
Dim id As String = ScriptManager.GetCurrent(Page).AsyncPostBackSourceElementID
Dim Obj = UpdatePanel1.FindControlRecursive(id)
If Not IsNothing(Obj) Then
a = 1
End If
End If
below the function used to find de object inside the update panel. Is an extension of System.Web.UI.Control
a=1 Is the desired code.
Public Module thisExtensions
_
Public Function FindControlRecursive(control As System.Web.UI.Control, id As String) As System.Web.UI.Control
If control Is Nothing Then
Return Nothing
End If
'try to find the control at the current level
Dim ctrl As Control = control.FindControl(id)
If ctrl Is Nothing Then
'search the children
For Each child As Control In control.Controls
ctrl = FindControlRecursive(child, id)
If ctrl IsNot Nothing Then
Exit For
End If
Next
End If
Return ctrl
End Function
End Module