With tracing disabled during normal page execution, SaveViewState is called only
once.
SaveControlState Method
The SaveControlState method saves the control state changes to ViewState. Overriding this
method is only necessary when a control needs to customize state persistence in control state.
Control state may or may not be used by a server control. In contrast to ViewState, control state
cannot be disabled by the developer user. Control state is stored using the same mechanism of
ViewState, but it cannot be turned off like ViewState.
Render Method
You are, by now, very familiar with overriding the Render method in a custom control to generate a
control??™s UI. The HtmlTextWriter class does the bulk of the work here, writing out the control
as HTML and script where applicable to the HTTP response stream. Note that any changes to
CHAPTER 5 ?– SERVER CONTROL EVEN TS 247
a control??™s state made within this method will render into the UI but will not be saved as part
of ViewState.
Unload Event
The Page class implements this method to perform cleanup. Overriding the OnUnload method
from the base control class allows the control to hook into this event. Although the Unload
event is an opportunity for a control to release any resources that it has obtained in earlier
control events such as Init or Load, it is recommended that you release resources in its Dispose
method.
Pages:
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352