Panels and dynamic controls...again

Discussion in 'ASP .Net Web Controls' started by PZ, Jan 12, 2009.

  1. PZ

    PZ Guest

    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?
     
    PZ, Jan 12, 2009
    #1
    1. Advertising

  2. 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

    http://www.nathansokalski.com/

    "PZ" <> wrote in message
    news:...
    > 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?
    >
    >
     
    Nathan Sokalski, Jan 15, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGVtZXRyaQ==?=

    User Controls vs. Panels

    =?Utf-8?B?RGVtZXRyaQ==?=, Dec 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    418
    Kevin Spencer
    Dec 19, 2005
  2. Ronald
    Replies:
    2
    Views:
    862
    Robbe Morris [C# MVP]
    Jan 17, 2006
  3. amit
    Replies:
    0
    Views:
    402
  4. che
    Replies:
    2
    Views:
    512
  5. Denny Smolinski via .NET 247

    Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

    Denny Smolinski via .NET 247, May 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    487
    Eidolon
    May 4, 2004
Loading...

Share This Page