LoadControl Method (Type, Object[])
Collapse the table of content
Expand the table of content

TemplateControl.LoadControl Method (Type, Object[])

Loads a Control object based on a specified type and constructor parameters.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public Control LoadControl(
	Type t,
	Object[] parameters
)

Parameters

t
Type: System.Type
The type of the control.
parameters
Type: System.Object[]
An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If parameters is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.

Return Value

Type: System.Web.UI.Control
Returns the specified UserControl.

If the user control supports caching, the object returned from the LoadControl method is not actually a UserControl object; rather, it is a PartialCachingControl object.

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 Init event rather than in the Load event.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2016 Microsoft