Where to add dynamic controls in the asp.net page life cycle?

There are some things in software development that I just keep having to re-read. One such subject that refuses to stay in mind is where in the asp.net page life-cycle should I; a) add dynamic controls b) set the properties of those controls c) read user saved values from those controls. So as an aid-mémoire:

OnInit – Create the dynamic controls. This is the basic place to create controls, without getting into the whole re-loading of the cycle when adding child controls.
Page_Load – read user saved values and set control values. This is used ’cause proving the dynamic controls have already been created (see above) then the viewstate and post-back mechanisms will have loaded the correct user set values.

There, why is that so hard to remember?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s