Solved

How can I determine the event that caused a Page_Load?

Posted on 2006-07-03
4
666 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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