Posted
on Jun 14, 2006
(permalink)
the code you suggested does not take into account other callbacks like the grid or treeview callbacks. i think this approach is better because it does not care about the posted data so if telerik changes the name of the parameter in the query string my code would still run
Public ReadOnly Property IsAjaxCallback() As Boolean
Get
Return IsAjaxCallbackRecursive(Me.Controls)
End Get
End Property
Private Function IsAjaxCallbackRecursive(ByVal ContainedControls As System.Web.UI.ControlCollection) As Boolean
For Each Ctl As System.Web.UI.Control In ContainedControls
If TypeOf Ctl Is Telerik.WebControls.CallbackControls.ICallbackControl Then
Dim CBProps As Telerik.WebControls.CallbackControls.ICallbackControl = CType(Ctl, Telerik.WebControls.CallbackControls.ICallbackControl)
If CBProps.IsCallback Then Return True
ElseIf TypeOf Ctl Is Telerik.WebControls.RadComboBox Then
If CType(Ctl, Telerik.WebControls.RadComboBox).IsCallBack Then Return True
ElseIf TypeOf Ctl Is Telerik.WebControls.RadGrid Then
If CType(Ctl, Telerik.WebControls.RadGrid).IsAsyncRequest Then Return True
ElseIf TypeOf Ctl Is Telerik.WebControls.RadTreeView Then
If CType(Ctl, Telerik.WebControls.RadTreeView).IsCallBack Then Return True
End If
'run recursive
If Ctl.Controls.Count > 0 Then
If IsAjaxCallbackRecursive(Ctl.Controls) Then
Return True
End If
End If
Next
End Function