I've got a situation where I need the code in a user control to run before the page it is sitting in. To do this I am trying to use a method other than Page_Load for the user control so the code is called and runs first. My first attempt was to use
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
This of course did run the code of the user control before the code on the page, however, in the code for the user control I am creating many controls dynamically and adding them to panels. It seems that everything that is supposed to be added dynamically is missing when the code executes in the Page_Init() method.
Doing a little more research, I found the methods Page_InitComplete() and Page_PreLoad. But neither one of these seems to work for user controls.
Any suggestions as to how I might tackle this problem?