June 2002
Intermediate to advanced
816 pages
28h 12m
English
LoadControl
objControl = Page.LoadControl(strPath)
Returns
an instance
of the user control defined in the strPath
user control file. This allows dynamic loading of user controls
instead of using the @ Register directive.
objControl
An object of type Control that represents the user control specified in the given path.
strPath
The virtual path to a user control file.
The example uses the LoadControl to load a user control at runtime and adds it to the page’s Controls collection:
Sub Page_Load( )
Dim Hello As UserControl = LoadControl("hello.ascx")
Page.Controls.Add(Hello)
End SubThe user control hello.ascx is as follows:
<h1>Hello, World!</h1>
Read now
Unlock full access