Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

handle event before Page_Load

I have an asp.net web page with a ton of code that is handled in the Page-Load event of the page. I also have a dropdown box on the page that should reload the page with a new value, but I would like to get this new value before I process the entire Page-Load code. I am trying to get my head around ASP.NET page lifecycle.

Should I move the Page-Load code to a later event or is there a way to get the value of the dropdown list value before the the Page-Load event begins?

TIA

like image 647
zkent Avatar asked Dec 17 '08 07:12

zkent


People also ask

Does master page load before content?

The content page load event will fire before the master page load event. Copying incase link goes dead: The following is the sequence in which events occur when a master page is merged with a content page: Content page PreInit event.

What is the difference between Page_Load and Page_Init?

Note that the Page_Init event fires only the first time the page is loaded. When you use a web form and post back to this page again, the Page_Init event doesn't fire. But the Page_Load event fires each time the page loads.

What is a Page_Load event?

The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets and images. This is in contrast to DOMContentLoaded , which is fired as soon as the page DOM has been loaded, without waiting for resources to finish loading.

At which event of page life cycle the master page is loaded?

Master pages behave like child controls on a page: the master page Init event occurs before the page Init and Load events, and the master page Load event occurs after the page Init and Load events.


2 Answers

I would use Page_PreLoad instead of Page_Init, because it is raised after all postback data is processed.

like image 188
Martin Moser Avatar answered Sep 26 '22 22:09

Martin Moser


Try Page_Init

like image 32
John Sheehan Avatar answered Sep 25 '22 22:09

John Sheehan