My application dbscript has a simple page structure for most pages: Each page related to a single record has a menu control displaying the links and actions for the current record.
For example, the Project page proj_edit.aspx embeds a proj_menu.ascx control, which retrieves some data from the database in the control’s Page_Load event.
If you want to access this data from the embedding page through the ascx control, you cannot access it in the page’s Page_Load event, as the Page_Load of the control has not yet fired. There is another event, less known (at least I did not know it), called Page_LoadComplete, which fires after each embedded control’s Page_Load has been processed.
To implement a Page_LoadComplete event in a page, you need to set
in the @Page directive of the aspx file.
Then simply add the lines
protected void Page_LoadComplete(object sender, EventArgs e)
to your page class in the aspx.cs file.
I posted about the ASP.Net page life cycle about a year ago, but recently came across this post which has a more detailed diagram on the page and control life cycle.
Download it. Memorize it. Make it your desktop background!😉