LoadControl v calling constructor

A

a

Hi
Extremely easy question for someone who knows the answer I'm sure
:) (aren't they all)

What exactly does LoadControl do? Whats the difference between calling
this and just constructing a user control?

Thanks

anon'ish
 
A

AW

You need to understand the difference between Web Custom Controls and Web
User Controls.

Web Custom Controls, like the WebControls (DataGrid, Button, ...) are
classes. To create them you just call their constructor:
Dim b as Button = new Button()

Web User Controls are defined by an ASCX page (containing HTML) and a class.
The class is just the codebehind for the control, so if you call its
constructor you don't create the control. That's where the LoadControl
method is needed: you pass it the name of the ASCX page, and it loads both
this page and the CodeBehind class.
 
J

Jerry III

When you create an ascx file you can specify the class name of the auto
generated class. The question is what is the difference between calling
LoadControl and calling a constructor of the generated class?

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top