I ran into the same problem and struggled after 5-6 hours. I am posting this, maybe someone like me can get help.
1) You must initialize your controls in the Page.PreInit event. (In my case, I had to add my controls to the place holder, so I pre-expanded PreInit to load these controls, but you don't need to do this. It depends on your scenario.)
2) You must bind these exact methods to your controls after they are initialized in your Page.PreInit event.
Here is my sample code:
protected override void OnPreInit(EventArgs e) { // Loading controls... this.PrepareChildControlsDuringPreInit(); // Getting ddl container from session and creating them... if (GetDDLSession().Count != 0) { foreach (DropDownList ddl in GetDDLSession()) { ddl.SelectedIndexChanged += SelectedIndexChanged; phDropDowns.Controls.Add(ddl); } } base.OnPreInit(e); } public static void PrepareChildControlsDuringPreInit(this Page page) { // Walk up the master page chain and tickle the getter on each one MasterPage master = page.Master; while (master != null) master = master.Master; }
user1409350
source share