When creating a new WebForm, Visual Studios creates the Page_Load handler in the default code, which is very cool. Therefore, for many years I have always been adding code to do things like the specified properties of controls in Page_Load. I recently used Reflector to view some assemblies written by Microsoft, and saw that they applied the same type of logic in the OnLoad method (which supposedly triggers a load event). So I started to wonder where it is best to set the properties of controls in OnLoad or Page_Load? Or in a completely different way? And if not Page_Load, why does Studio add this to the code for?
My last thought: Although I know that setting the logic in OnLoad works fine, I will probably stick with Page_Load because this is normal. I asked if I could really find out if I was missing something new after I started to see that OnLoad appears in other people's code. Thank you all for your thoughtful answers!
source
share