views:

28

answers:

2

Hi just wondering if there is anyway that I could duplicate controls in a asp.net pages.

So for example, currently for one of my pages, I have a panel at the top of the page with alot of controls in them ( eg next/previous buttons, labels, trees, etc).

However I wanted to add the exact duplicate of this panel on the bottom of the page aswell, with exact functionality.

Is there a easy way to do this, or do I need to do it manually...

Thanks

+1  A: 

One option is to place all the controls inside a UserControl. Then include the UserControl once at the top and once at the bottom.

If you do this then wiring up all events might be more difficult, though.

Eilon
thanks for the suggestion, however I am trying to avoid using user controls since for this panel is already nested in a few user controls itself (it will get even more ugly, *sigh)
skub
@skub, that's the very reason that User Controls exist in ASP.NET - to group together bits of UI that can be reused in multiple places.
Eilon
A: 

What you're after is either UserControls or Master Pages, or a combination of both.

Nick Craver
Master pages don't seem to apply here, but UserControls certainly do. If you feel master pages do apply then please explain how.
Eilon
@Eilon If someone is unfamiliar with UserControls it's highly likely that they're also unfamiliar with Master pages as well...skub may find a lot of benefit looking at these at the same time and saving even more duplication. They are very similar...after all, Master Pages are actually UserControls.
Nick Craver
@Nick, I'm just trying to understand how using master pages helps answer this question. Have you found a clever way to use them in this scenario? If so I'd definitely like to see it.
Eilon
Ah yes, in direct response to the question maybe he wouldn't use them for this once instance...but when designing a site to have a consistent look and feel, e.g. controls available at the top and bottom of the page, then Master Pages are tremendously useful. If skub ends up making more pages like this, a master or nester master may again save a lot of duplicates pasting of the UserControls that would solve the current situation.
Nick Craver
ok thanks guys for the tips - I'll group this into a user control then.Cheers
skub