TrackViewState Method
The TrackViewState method executes immediately after initialization and marks the beginning
of ViewState processing, and state tracking, in the control life cycle. If you have attribute values
that you do not want to save in ViewState across page round-trips for efficiency purposes, you
should set these values in the OnInit method. Otherwise, all control property value modifications
performed after this method executes will persist to ViewState.
246 CHAPTER 5 ?– SE RVER CONTROL EVENTS
If desired, you can make modifications to state values in this method that won??™t be marked
as dirty as long as you do so before executing the inherited base.TrackViewState method or
before calling the encapsulated StateBag.TrackViewState method.
Load Event
The Load event should be quite familiar to you, because we have leveraged this convenient
location for common page code in our web forms in previous examples. It is a handy place to
put page initialization logic, because you are guaranteed that all controls in the Page??™s control
tree are created and all state-loading mechanisms have restored each control??™s state back to
where it was at the end of the previous request/ response page round-trip. This event also
occurs before any controls in the Page??™s control tree fire their specific events resulting from
value changes in postback data.
Pages:
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350