Dynamic control creation design issue

G

Guest

Hi!

I have been wondering about a design issue for some time now and hope
someone can help sort this one out for me.

Say you have to create some webcontrols dynamically. Each controls creation
is dependent on another’s selected value. That is, you can’t create control B
if you don’t know the value of control A. There is no problem this far. I’ve
done some testing and if I always create the control in Page_Init, ASP.NET
has filled its value property for me when I’m in Page_Load. Thus I have the
information I need in order to create control B. We can consider my controls
as a custom webcontrols that is dependent of some value in the constructor in
order to be created properly.

So, if I am to create a third control, control C, that is dependent of the
value of control B, I now have to this in Page_PreRender. Control B isn’t
created before Page_Load, and its value property therefore isn’t set until
the next event occurs in the event stages, which as far as I know Is
Page_PreRender.

I actually was forced to do all of this in a recent project, and made me
wondering if I’m doing this correctly, because if I am, what happens if I am
to create a fourth control, control D, that is dependent of control C created
in Page_PreRender? As far as I know there are only Page_Init, Page_Load and
Page_PreRender, and if a control is created in one of them, its value isn’t
set until the next of these events occurs. In former projects, I used to get
the values directly from the Request.Form collection. This way all these
problems are solved, but it just doesn’t seem to be the .NET way to do it. :)

I would be glad if you want to share your thoughts about this one, am I
missing some basics here or is there simply no .NET-ish way of doing this?

Thanks
/Paul
 

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

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top