Share via


OnLoad(System.EventArgs) Method

The OnLoad method of the WebPart class is the event handler for the System.Web.UI.Control.Load event, indicating that a Web Part is being loaded into the Web Part Page.

Parameters

e   A System.EventArgs that contains the data for the System.Web.UI.Control.Load event.

Remarks

If your Web Part needs to perform actions common to each HTTP request for the page it is associated with, such as setting up a database query, you can subscribe to the System.Web.UI.Control.Load event by adding an appropriate event handler in the Web Part constructor. For example:

this.Load += new EventHandler (MyLoadHandler);

At this stage in the Web Part's life cycle, server controls in the hierarchy are created and initialized, the view state is restored, and the form controls reflect client-side data.

Requirements

Platforms: Windows Server 2003

Security: Code Access Security