By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,812 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,812 IT Pros & Developers. It's quick & easy.

Dynamic control creation design issue

P: n/a

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

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?

Feb 21 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.