Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5

  Switch on low bandwidth view
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
TemplateControl..::.LoadControl Method

Loads a Control.

  NameDescription
Public methodLoadControl(String) Loads a Control object from a file based on a specified virtual path.
Public methodLoadControl(Type, array<Object>[]()[]) Loads a Control object based on a specified type and constructor parameters.
Top

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.

TopicLocation
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
clarification      Ninja Coder   |   Edit   |   Show History

"When you load a control into a container control,"

This means you have to Control zzzzzzzzzz = yyyyyyyyy.LoadControl() then xxxxxxxx.controls.Add(zzzzzzzzzz);

Note xxxxxxxx and yyyyyyyyy do not need to be the same templateControl (for example I use the page to loadcontrol and then a placeholder within a control on the page to add it.) when the control is added the events are called.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker