Solved

How can I determine the event that caused a Page_Load?

Posted on 2006-07-03
4
665 Views
Last Modified: 2008-01-09
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
Comment
Question by:Jens Fiederer
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 17031361
you can know it setting a flag in all objects events and in the page_prerender you'll get the value
0
 
LVL 23

Author Comment

by:Jens Fiederer
ID: 17033147
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
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 17035585
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
 
LVL 23

Author Comment

by:Jens Fiederer
ID: 17041881
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question