Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Iterate through all panels on webform?

Thread Tools

Iterate through all panels on webform?

Rob Meade
Posts: n/a
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, panel 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.



Reply With Quote

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
Iterate through Panels Fabian ASP .Net 2 10-04-2004 09:43 PM