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

Is there a way to reuse dynamic controls with multiple parents?

P: n/a
So I have a composite paging control that shoulld be positioned on the page
like this:

PagNav
ResultSetDisplay
PagNav

I know that I can't resuse the PagNav more than once in the form, so I
instantiate a couple of instances, PagNavTop and PagNavBottom, and thus I
end up with:

PagNavTop
ResultSetDisplay
PagNavBottom

The paging navigators are composed of a bunch of dynamically generated
LinkButtons and Lables. And since they should appear on the page
identically, I don't want to do the extra dynamic control creation and
calculation for the bottom one. I thought I might just re-use the same
LinkButtons and Labels in both top and bottom.

Alas, the ASP.NET framework boobytraps the dynamic controls if they're added
to another control ini the same form. Once I add them to PagNavBottom --
after adding them to PagNavTop -- they vanish from PagNavTop and will only
show up in the last parent they've been added to, PagNavBottom.

It's waste of processor cycles and memory to recreate a brand new set of
controls to each parent. I'm pretty sure that many people here in this group
have bumped into this issue, and I appreciate your feedback on how you'd
attack such a problem.

Homam
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I found out this is not possible: In ASP.NET, each control points to a
single parent. So we have the parent pointing to all the children
(Control.Controls) in addition to the child pointing up to the parent
(Control.Parent). That's why the control will always point to the last
parent it's been added to.

The quick and dirty solution is to render the controls as static HTML string
and reuse that in both places.

But I'm curious if there are neater yet efficient ways to do it.

"Homam" <ho*********************@hotmail.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
So I have a composite paging control that shoulld be positioned on the
page like this:

PagNav
ResultSetDisplay
PagNav

I know that I can't resuse the PagNav more than once in the form, so I
instantiate a couple of instances, PagNavTop and PagNavBottom, and thus I
end up with:

PagNavTop
ResultSetDisplay
PagNavBottom

The paging navigators are composed of a bunch of dynamically generated
LinkButtons and Lables. And since they should appear on the page
identically, I don't want to do the extra dynamic control creation and
calculation for the bottom one. I thought I might just re-use the same
LinkButtons and Labels in both top and bottom.

Alas, the ASP.NET framework boobytraps the dynamic controls if they're
added to another control ini the same form. Once I add them to
PagNavBottom -- after adding them to PagNavTop -- they vanish from
PagNavTop and will only show up in the last parent they've been added to,
PagNavBottom.

It's waste of processor cycles and memory to recreate a brand new set of
controls to each parent. I'm pretty sure that many people here in this
group have bumped into this issue, and I appreciate your feedback on how
you'd attack such a problem.

Homam

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.