Any ideas how to check which control in an asp.net web application raised a postback?
I have a number of buttons, and want to perform a different task in the Page_Load method depending which button was clicked.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To check which control caused the postback, use Request.Form["__EVENTTARGET"]. This should return a unique ID of the control that caused the postback.
EDIT
For this to work you will have to set
UseSubmitBehaviorproperty of the button to false which causes it to use Asp Net post back mechanismFrom MSDN