ASP.NET - Dynamic controls created in Page_Pre_init() or Page_Init() or Page_Load()
.net, asp.net, dynamic
Solution
I recommend Page_Init(). This will bypass the issue of ViewState not loading consistently. Controls will be accessible, but viewstate not yet applied to them. This is exactly where you want to add controls per the second article.
Also, based on experience, this is what works. any other approach else has caused me issues.
Problem
Where is the best place to create dynamic controls in ASP.NET? MSDN says Pre_init , another MSDN article says Init, and some people say the Load event (which I read isn't good to do). I'm studying for a MS certification and I want to make sure I know which one is ideal and why. My initial thought would be to create the object in pre_init and assign any property values in the Load event (so that ViewState would be loaded for the dynamic control).