(11)UnLoad This event is used for cleanup code. After the page’s HTML is rendered, the objects are disposed of. During this event, you should destroy any objects or references you have created in building the page. At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object. Cleanup can be performed on-

(a)Instances of classes i.e. objects

(b)Closing opened files

(c)Closing database connections.

EXAMPLE : Override the event as given below in your code-behind cs file of your aspx page

protected  void Page_UnLoad(object sender, EventArgs e)

{//  This event occurs for each control and then for the page. In controls, use this  event to do final cleanup for specific controls, such as closing  control-specific database connections.
//  During the unload stage, the page and its controls have been rendered, so you  cannot make further changes to the response stream.            
//If  you attempt to call a method such as the Response.Write method, the page will  throw an exception.
}

Similar Topics:

Tags:

asp net page life cycle events with exampleasp net page life cycle with examplepage life cycle in asp net with exampleasp net page life cycle in detailasp net life cycle in detailasp net page life cycle examplepagelife cycle in asp net with examplepage life cycle in asp netasp net page life cycle with examplespage life cycle events in asp net with examples