Many thanks to Ryan Farley (http://www.ryanfarley.com/blog/archive/2005/03/11/1886.aspx) for this code. I converted the C# to VB for my own project. Saved my sanity it did!Public Shared Function GetPostBackControl(ByVal page As Page) As Control
Dim control As Control = NothingDim ctrlname As String = page.Request.Params.[Get]("__EVENTTARGET")
If ctrlname IsNot Nothing AndAlso ctrlname <> String.Empty Then
control = page.FindControl(ctrlname)
Else
For Each ctl As String In page.Request.Form
Dim c As Control = page.FindControl(ctl)
If TypeOf c Is System.Web.UI.WebControls.Button Then
control = c
Exit For
End If
Next
End If
Return control
End Function
-
GetPostBackControl
@ 2008-05-01 – 12:47:53
