I have a page with a user control that has a dropdownlist for date. When the user control loads for the first time, I populate the year options using one of our toolbox methods. When the webform (the user control's host) loads for the first time, I also look in a database to see if there is a date stored that I should use to populate the date field. However, this latter thing was failing on the year field. Eventually I determined it is because the code to load the date from a database was running before the year field had any options - before the user control was fully loaded in other words.
I found these 2 articles that discuss the order of the page lifecycle, and list the lifecycle events:
ASP.NET Page Life Cycle Overview
Page Events in ASP.Net 2.0
I decided to use the LoadComplete() event, which also lets you test for PostBack, which I needed since I only wanted the databinding for the date to happen on first page load.
Just thought I'd mention this in case anyone else ever runs into a similar issue, and also to see whether anyone thinks a different event would have been better to hook into, like maybe Pag_PreRender.
Showing posts with label loadcomplete. Show all posts
Showing posts with label loadcomplete. Show all posts
Thursday, August 20, 2009
Subscribe to:
Posts (Atom)