Efficiency of dynamically adding web user controls

M

MC D

When I dynamically add a control by doing something like

dim x as control = Page.LoadControl("myControl.ascx")

am I actually loading the control from disk??? I don't really understand why
I can't access the class for the user control directly... in other words
just say:

dim x as new myControl()

(which doesn't generate an error, but it wil not render the UI)

If I'm adding a control dozens of times on a page, is this very
in-efficient?

Thanks for any help!

-D
 
M

Marina

User controls bear some resemblence to include files. Of course they are
object oriented, much more flexible, etc.

There are many large systems that rely on include files, and those work ok -
so I would imagine user controls wouldn't be any worse.
 
C

-=Chris=-

Do not forget that some user controls are not just classes, but also contain
html snippets in the actual ascx file. It is for the purpose of retreiving
both the class, and the html within the ascx file, that page.loadcontrol()
is used.

User Controls are most helpful when creating commonly used UI components.
If your user control has no associated html in the .ascx file, I'd recommend
creating a simple class or a server control instead.



I was minding my own business when MC D blurted out:
 

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,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top