You can use the OnInit method to trap this event and initialize member variables and other values.
LoadViewState
You can trap this event to customize how the control retrieves information from the ASP.NET hidden ViewState field.
Load
This event is raised after you create and initialize the control. This is the best place to make the connection to the database or load document content. You can trap the Load event by adding the OnLoad method to the class.
PreRender
This event is raised before ASP.NET renders the control. Any changes to the control's state are saved into the hidden ViewState field.
SaveViewState
This event is raised before the control state is persisted into the hidden ViewState field. You can trap the event to customize how this information is stored.
Render
You can use the Render method to respond to this event and specify the HTML code that represents the component's content.
Dispose
This event is useful for cleanup operations. It's raised before the control is torn down and is the best place to free the resources created during the load phase.
Unload
This event is raised before the control is torn down. The official documentation says not to use this event to perform cleanup, and to rely on the Dispose event instead.
Table 1Trap Events to Customize Behavior. You can trap these events to customize an ASP.NET custom control's behavior. The Render method, which lets you add HTML code to build your control, is especially useful.