ASP.NET Custom Control Lifecycle
November 1, 2009 by Nauman · Leave a Comment
I always forget the lifecycle of custom server control classes with respect to web page, ie. aspx file.
The following results are based on a drop down list custom control:
customcontrol – Constructor
customcontrol – OnInit – Enter
customcontrol – OnInit – Exit
webpage – OnInit – Enter
webpage – OnInit – Exit
webpage – Page_Load – Enter
customcontrol – could be altered here in page load, causing some event to fire
webpage – Page_Load – Exit
customcontrol – OnLoad – Enter
customcontrol – OnLoad – Exit
POSTBACK:
customcontrol – Constructor
customcontrol – OnInit – Enter
customcontrol – OnInit – Exit
webpage – OnInit – Enter
webpage – OnInit – Exit
customcontrol – LoadViewState – Enter
customcontrol – LoadViewState – Exit
webpage – Page_Load – Enter
webpage – Page_Load – Exit
customcontrol – OnLoad – Enter
customcontrol – OnLoad – Exit
customcontrol – OnSelectedIndexChanged – Enter
webpage – xx_SelectedIndexChanged – Enter
customcontrol – could be altered here in page load, causing some event to fire
webpage – xx_SelectedIndexChanged – Exit
customcontrol – OnSelectedIndexChanged – Exit