Few lines about PreRender eventWelcome to CodeSpread!
To know PreRender and understand its importance, we should know the events before it and after it. We start with,
Page object including all controls are loaded and the page is ready to be rendered to the output. Here, as a last event before PreRender, Handle Postback event is fired.
Handle PostBack Event: This event is caused by the postback trigger of any controls from client side.
Prerender: For this event, all controls are available and it is the last stage where we have access to the controls so any operation before the server control is rendered can be performed here. Any changes in the view state of the server control can be saved during this event.
Save ViewState: ViewState is a property of a control and for all the controls, their viewstate will be saved to their own viewstate collection. The resultant viewstate is serialized, hashed, base24 encoded and is sent to the client as a hidden variable, _viewstate.
Page is rendered to the client in HTML form.
Conclusion: PreRender event is used to make final changes to the contents of the page or its controls before the rendering stage begins.
Note: Databinding is raised after the control’s PreRender event, This event marks the beginning of the process that binds the control to the data.