Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Is there a way to reuse dynamic controls with multiple parents?

Reply
Thread Tools

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

 
 
Homam
Guest
Posts: n/a
 
      03-04-2005
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


 
Reply With Quote
 
 
 
 
Homam
Guest
Posts: n/a
 
      03-04-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To reuse or not to reuse jacob navia C Programming 19 12-18-2006 07:22 AM
Reuse DataSource with multiple user controls Amil Hanish ASP .Net 0 08-21-2006 12:37 PM
code reuse and design reuse sailor.gu@gmail.com C Programming 16 02-12-2006 09:09 PM
Reuse paramter list and reuse connection tshad ASP .Net 5 05-17-2005 12:33 AM
To reuse or not to reuse.... Hylander Java 0 02-26-2004 12:00 AM



Advertisments