string controlID = Page.Request.Params["__EVENTTARGET"];
Control postbackControl = null;
if (controlID != null && controlID != String.Empty)
{
postbackControl = Page.FindControl(controlID);
}
else
{
foreach (string ctrl in Page.Request.Form)
{ //Check if Image Button
if (ctrl.EndsWith(".x") || ctrl.EndsWith(".y"))
{
postbackControl = Page.FindControl(ctrl.Substring(0, ctrl.Length - 2));
break;
}
else
{
postbackControl = Page.FindControl(ctrl);
//Check if Button control
if (postbackControl is Button)
{
break;
}
}
}
}
Response.Write(postbackControl.ID);
No comments:
Post a Comment