• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 690
  • Last Modified:

How can I determine the event that caused a Page_Load?

When an event triggers a postback, I normally see a Page_Load occur before the event handler is called.

Is there any way WITHIN the Page_Load handler for me to tell which event triggered the postback?
0
Jens Fiederer
Asked:
Jens Fiederer
  • 2
1 Solution
 
Elvio Lujan.Net Senior DeveloperCommented:
you can know it setting a flag in all objects events and in the page_prerender you'll get the value
0
 
Jens FiedererTest Developer/ValidatorAuthor Commented:
page_prerender is not Page_Load.

Are you trying to say there is no way to tell IN Page_Load?

And what do you mean by "setting a flag in all objects events"?
0
 
David H.H.LeeCommented:
jensfiederer ,
Request.Form("__EVENTTARGET") will return the name of the control that caused the postback. Based on the retrieved control name, you'll know which event triggered the postback as well.
0
 
Jens FiedererTest Developer/ValidatorAuthor Commented:
That was useful, x_com.

Not quite what I asked for: there must be situations where more than one type of event causes postback for a control, and also this does not always work (I get a blank when pushing the button).

But it is quite likely that what I asked for does not exist, and in my situation this solves my problem splendidly!  So I am happy!

Note for when this is PAQed:  the "name of the control" is not the .NET name but the HTML form name.  So when a radiobuttonlist gets clicked, you will see selOperation_0 or selOperation_1, not selOperation.

Thank you!
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now