Skip to content

Instantly share code, notes, and snippets.

@icodejs
Created April 16, 2012 10:28
Show Gist options
  • Save icodejs/2397541 to your computer and use it in GitHub Desktop.
Save icodejs/2397541 to your computer and use it in GitHub Desktop.
what page control caused postback?
public function getPostBackControl(page as Page) as string ' what control caused postback?
dim control as control = nothing
dim ctrlname as string = page.request.Params("__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.ID
end function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment