Dheeman Dutta

Just Another Blog.....

  Home  |   Contact  |   Syndication    |   Login
  39 Posts | 1 Stories | 29 Comments | 12 Trackbacks

News



Archives

Post Categories

.NET Links

Wednesday, April 04, 2007 #

public static Control GetPostBackControl(Page page)
{
    Control control = null;

    string ctrlname = page.Request.Params.Get("__EVENTTARGET");
    if (ctrlname != null && ctrlname != string.Empty)
    {
        control = page.FindControl(ctrlname);
    }
    else
    {
        foreach (string ctl in page.Request.Form)
        {
            Control c = page.FindControl(ctl);
            if (c is System.Web.UI.WebControls.Button)
            {
                control = c;
                break;
            }
        }
    }
    return control;
}

 

The above code is taken from http://ryanfarley.com/blog/archive/2005/03/11/1886.aspx ... A beautiful example...

 

Cheeers..