System.Web.UI.TemplateControl.LoadControl Method

Loads a System.Web.UI.Control object from a file based on a specified virtual path.

Syntax

public Control LoadControl (string virtualPath)

Parameters

virtualPath
The virtual path to a control file.

Returns

Returns the specified System.Web.UI.Control.

Remarks

If the control supports caching, the object returned from the TemplateControl.LoadControl(string) method is not actually a System.Web.UI.Control object; rather, it is a System.Web.UI.PartialCachingControl object. If the virtualPath parameter is relative, the path of the loaded control is relative to the path of the System.Web.UI.TemplateControl.

When you load a control into a container control, the container raises all of the added control's events until it has caught up to the current event. However, the added control does not catch up with postback data processing. For an added control to participate in postback data processing, including validation, the control must be added in the Control.Init event rather than in the Control.Load event.

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0