I need to build user controls dinamically, is possible?

L

leon

Hello everybody.

I need to build user controls dinamically into aspx page.

Besides of this, i need to put into each userscontrol different controls,
add to every control its control validators and its events.

If someone has some idea, i will say Thanks a lot.

leon
 
J

John Saunders

leon said:
Hello everybody.

I need to build user controls dinamically into aspx page.

Besides of this, i need to put into each userscontrol different controls,
add to every control its control validators and its events.

If someone has some idea, i will say Thanks a lot.

You can dynamically "build" a custom server control. That is, you can create
a custom control which dynamically decides which controls it will contain.

It won't be a .ascx file, though.
 
S

Sahil Malik

Leon,

The answer is Page.LoadControl ... but keep reading ..

This is a classic problem even framework 2.0 fails to solve appropriately.

user controls are a combination of ascx and a code behind file in framework
1.1 and a partial class and code beside class in framework 2.0. The way they
work is, in 1.1 inherited code and in 2.0 combined code is compiled at
runtime and an Activator.CreateInstance is called on the URL location of the
ascx, similar to a webservice call .. it is like a server activated object.

So while the ascx interface is fun to play with and intuitive, (etc. etc.),
you cannot do a "new" on a usercontrol. ....

HOWEVER .. you can do a Page.LoadControl :) which comes darned close.

The only thing you cannot do is put UserControls along with ascx's in a dll
and distribute that as a product. That is not possible to do :)

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top