See:
How does ASP.NET
recognize the control
responsible for handling the postback?
When no controls referenced in the
request body implement the
IPostBackEventHandler
interface, the
page class looks for the __EVENTTARGET
hidden field, if any. The contents of
the field is assumed to be the ID
of
the control that caused the postback.
If this control implements the
IPostBackEventHandler
interface, the
RaisePostbackEvent
method is invoked.
this is from here - The Client Side of ASP.NET Pages.
So at the client-side __EVENTTARGET
is all you need. At the server-side you could either override the Page.RaisePostBackEvent
method (this is protected method, so you could inherit from System.Web.UI.Page
class):
protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl,
string eventArgument)
{
// sourceControl is a control that caused postback
base.RaisePostBackEvent(sourceControl, eventArgument);
}
or perform the same without inherining:
var controlName = page.Request.Params["__EVENTTARGET"];
Control postbackControl = null;
if (!string.IsnullOrEmpty(controlName))
{
postbackControl = this.Page.FindControl(controlName);
}
EDIT: regarding the author's comment to my answer: if __EVENTTARGET
value is an empty string, it seems you're getting this value before it is been set in __doPostBack
function. So the workaround could be in overriding __doPostBack
function or a similar way; you could find an example of doing it in this SO quesion.