So, when should you do things? As a rule of thumb, I try to do data binding early (OnInit) and presentation setting late (OnPreRender, or in controls that output custom markup in the Render override). It's a tricky topic and something that seems to catch most developers - the concept of top-down development with classic ASP and PHP just doesn't apply.
There's an excellent article on MSDN about the order of events here: http://msdn.microsoft.com/en-us/library/ms178472.aspx.
For my future reference, some items to consider:
- Init and Load need to be handled carefully: the Init event for controls fires BEFORE the Init event for the Page; the Load event for controls fires AFTER the Load event for the Page.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.