Find the action trigger at Page_Load

  • Thread starter Thread starter jerryau
  • Start date Start date
J

jerryau

Hi,

Does anyone know how can I find what was the action trigger (button
pressed) at Page_Load? Because the Page_Load method is called first
everytime anything is posted to the server, I need to know what button
was pressed before performing anything in the Page_Load method. Is it
possible?

Thanks,
Jerry
 
Hi,

Does anyone know how can I find what was the action trigger (button
pressed) at Page_Load? Because the Page_Load method is called first
everytime anything is posted to the server, I need to know what button
was pressed before performing anything in the Page_Load method. Is it
possible?

Thanks,
Jerry

This will tell you the ID of the control:
string controlId = Page.Request.Form["__EVENTTARGET"];

Though I don't think that is documented behaviour, it's how ASP
manages control events under the hood, so could change in future
versions of ASP.
 
Does anyone know how can I find what was the action trigger (button
pressed) at Page_Load? Because the Page_Load method is called first
everytime anything is posted to the server, I need to know what button
was pressed before performing anything in the Page_Load method. Is it
possible?
Thanks,
Jerry

This will tell you the ID of the control:
string controlId = Page.Request.Form["__EVENTTARGET"];

Though I don't think that is documented behaviour, it's how ASP
manages control events under the hood, so could change in future
versions of ASP.

Thanks, that's exactly what I was looking for :)

Sorry for posting into the wrong forum, I didn't know there was an
asp.net forum as well :).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top