Iterate through all panels on webform?

R

Rob Meade

Hi all,

I have a page, where, because it had to all be in one page there are a
multitude of panels, with the use of a handful of conditions and the ability
to show/hide panels I am able to make this page look like the user is moving
between many...

Here's my problem...

I started off by simply seting the visibility to true/false etc in each code
block where I needed to turn them on or off - as I got more this was getting
painful, so I then created a sub, and for each panel passed in a true/false
value as a parameter...

For example

Private Sub ShowPanels(byval panel1 as boolean, byval panel2 as boolean,
byval panel3 as boolean)

panel1.visible = panel1
panel2.visible = panel2
panel3.visible = panel3

End Sub

*note, they are not named like that - its just an example!

This was working fine to start with but as I've grown the number of panels,
the parameters being passed in are getting quite big, and of course each
time I add one I have to go back through my code where I have the sub called
and update it- its getting to be a pain in my roses red....

So, what I'm looking for is something a bit clever...

What I was thinking was perhaps a sub which would iterate through a
collection of controls on the page, looking for just the "panels", once it
has all of those, set them all to visible = false apart from the ones I want
to show which would be specified in the parameters...

However, I can see some problems with this...

1. I have no idea how to iterate through the controls on the page just
looking for the panels...
2. Sometimes I need to show 1 panel, sometimes 2, something 4, so how can i
have a varying length list of parameters going in, ie, ShowPanels(panel1,
panel2, panel8) or ShowPanels(panel4, panel5)

Any help with this would be appreciated...

Its probably not the best of approaches, and I'm sure with .net 2 there are
many more clever ways of doing what I need to do - however I dont, currently
in this project have the luxury of time to learn too many new things - so
figured I'd go with something easier...

Thanks in advance for your time.

Regards

Rob
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top