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

H

Homam

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
 
H

Homam

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.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top