Home All Groups Group Topic Archive Search About

Panels and dynamic controls...again

Author
12 Jan 2009 3:25 AM
PZ
Sorry for posting again, been away for a while, just need to refresh this
issue.

I have a page on which I have 2 panels. Each panel has a DropDownList
control which is generated dynamically at init. The first panel (panel1) is
visible, while the other panel (panel2) is currently not visible.

Just wondering if there is a way around wasting time on creating the
controls for panel2, when it is not shown yet? I only want to create it when
panel2 becomes visible, but then I get into the classic page cycle problem,
where events and viewstates makes it impossible to keep values to the
dropdownlist dynamic.

Above is the simple solution. After some weeks of development, I have more
like 11 panels with alot of controls on each of them. Some dynamic, some
hardcoded items. I'm using viewstate and OnPrerender event to determine if a
panel should be visible. It works fine, but getting kind of slow when you
need to generate ALL controls and bind data at each cycle. If you need to
show one panel with one control, it's kind of frustrating that I need to
create 100+ controls before I can display that one control.

My goal is to keep everything on one aspx page, but not sure if this is the
right strategy if you have a rather large site with many functions and
controls.

Please advise.

There must be a better way to design this?

Author
15 Jan 2009 5:12 PM
Nathan Sokalski
One thing you could try is making each Panel into a UserControl (*.ascx) and
then setting the Visible property of that UserControl. You may also be able
to use the IsPostBack property in several places to help prevent unnecessary
renderings. I haven't done any testing on either of these, but they may
help. I wasn't quite sure from your posting, but if you are never showing
more than one Panel at a time, you may want to look into the MultiView
control. Even if it doesn't make your code more efficient as far as
rendering more controls than you will be displaying (maybe it does, I
haven't checked), it will definitely make your code more organized if you
are only displaying one at a time. I can't promise whether any of this will
help, but maybe they will give you some ideas. Good Luck!
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"PZ" <P*@discussions.microsoft.com> wrote in message
news:1318AD86-15EA-4D73-9DF7-98D68062EFAD@microsoft.com...
> Sorry for posting again, been away for a while, just need to refresh this
> issue.
>
> I have a page on which I have 2 panels. Each panel has a DropDownList
> control which is generated dynamically at init. The first panel (panel1)
> is
> visible, while the other panel (panel2) is currently not visible.
>
> Just wondering if there is a way around wasting time on creating the
> controls for panel2, when it is not shown yet? I only want to create it
> when
> panel2 becomes visible, but then I get into the classic page cycle
> problem,
> where events and viewstates makes it impossible to keep values to the
> dropdownlist dynamic.
>
> Above is the simple solution. After some weeks of development, I have more
> like 11 panels with alot of controls on each of them. Some dynamic, some
> hardcoded items. I'm using viewstate and OnPrerender event to determine if
> a
> panel should be visible. It works fine, but getting kind of slow when you
> need to generate ALL controls and bind data at each cycle. If you need to
> show one panel with one control, it's kind of frustrating that I need to
> create 100+ controls before I can display that one control.
>
> My goal is to keep everything on one aspx page, but not sure if this is
> the
> right strategy if you have a rather large site with many functions and
> controls.
>
> Please advise.
>
> There must be a better way to design this?
>
>