Template Events
The CodeTemplate object provides three events that you can use to insert logic during the template processing cycle:
The OnInit event fires when the template instance is created
The OnPreRender event fires just before the template is rendered
The OnPostRender event fires just after the template is rendered
The OnPropertyChanged event fires after a template property has changed.