Which Control Caused PostBack!
What is a Postback?
Working with web server controls, each action taken will cause the page to send HTTP POST to itself.
How to know which control caused the postback?
There are two hidden fields which will hold the control id and any extra argument. Once for example, you clicked on a button, a javascript event handler will handle this event. The __doPostBack() function will be fired which will set the control id in __EVENTTARGET hidden field and the arguments in __EVENTARGUMENT and finally it submits the form to the server.
So to know which control caused postback in code behind, you can use
string controlID = Request.Params["__EVENTTARGET"];
if controlID returned "" ( in .NET framework 1.1) you should consider trying
if(Request["BUTTONID"] != null)
{
// button is clicked
}
else
{
// Button is not clicked
}
Where BUTTONID Is the id of the button you are trying to figure if it was clicked or not
Hope this helps,
HC