SLX EntityBoundSmartPart lifecycle
Nicolas Galler | December 6, 2007I added some logging statements to figure out what the lifecycle of user controls implementing SLX smart parts was and how it meshed with the standard ASP.NET events. This is what I came up with. SLX-specific events are in italic – the rest are standard ASP.NET (I skipped a few of the ASP.NET ones).
When the smart part is not displayed (eg an undisplayed dialog), none of the SLX stuff fires, but the standard ASP.NET still does:
- OnInit
- OnLoad
- OnUnload
EntityContext.GetEntity() is available at all time but is of the type that is bound to the main form – not necessarily the same as the smartpart’s.
The first time it is displayed and bound:
- OnInit
- OnLoad
- OnAddEntityBindings
- OnLoadCurrentEntity starts
- OnCurrentEntitySet
- OnLoadCurrentEntity returns
- MyDialogOpening
- OnPreRender
- OnFormBound (which is actually called from OnPreRender)
- OnUnload
Again, EntityContext.GetEntity() is available but is of the type of the main form until OnCurrentEntitySet.
On postbacks:
- OnAddEntityBindings
- OnInit
- OnLoad Starts
- OnLoadCurrentEntity starts
- OnCurrentEntitySet
- OnLoadCurrentEntity returns
- OnLoad Returns
- Control postback events
- OnPreRender
- OnFormBound (which is actually called from OnPreRender)
- OnUnload
EntityContext.GetEntity() is available and of the correct type.
OnFormBound is not a bad place to hook data binding stuff but it only fires from the PreRender which is a bit late sometimes. OnCurrentEntitySet executes before the bound data is saved to the entity (therefore before any SLX property change handler fires) so it is usually not great either.






Nick,
This is great stuff. Thanks so much for getting this all figured out and sharing this.
-Ryan