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" <> wrote in message
news:...
> 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
>
>
|