Geeks With Blogs
Dheeman Dutta Just Another Blog.....

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..

Posted on Wednesday, April 4, 2007 10:57 AM | Back to top


Comments on this post: To Find a control that has caused the postback

# Links (4/4/2007)
Requesting Gravatar...
.NET DataTable vs. BindingList Very Lightweight Data Access Layer in C# and .NET 2.0 WeekNumber A final
Left by Member Blogs on Apr 25, 2007 2:41 PM

Your comment:
 (will show your gravatar)


Copyright © Dheeman Dutta | Powered by: GeeksWithBlogs.net