Problem with menu control and CreateChildControls

Discussion in 'ASP .Net' started by dorrit.Riemenschneider@communardo.de, Jan 8, 2007.

  1. Guest

    Hi,

    I develop a sharepoint webpart with ASP.Net 2.0 and therefore override
    CreateChildControls(). In CreateChildControls() I create dynamically a
    menu with items (and sub items) from a database. Let's say after the
    first loading I have 5 menu items.

    My problem: Every time the page is loaded (that means also if a menu
    item is clicked) the menu items are doubled (I have 10, 15, 20, ...
    menu items).

    How can I avoid this???

    Any help is appreciated!
    Dorrit
     
    , Jan 8, 2007
    #1
    1. Advertising

  2. There are a number of ways to do this. If the menu items in the db don't
    change frequently you can simply have a viewstate variable that is set once
    the menu items are loaded. If the viewstate variable isn't there or is set
    to true, you will know that the menu has been populated and doesn't need to
    be re-populated. Of course, the simplest way is to just nuke the contents on
    each load of the control but that is a performance hit on generation. What
    you have sounds like it's working well, you just need to prevent it from
    loading a new set of data every time the control is loaded.


    --

    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006


    <> wrote in message
    news:...
    > Hi,
    >
    > I develop a sharepoint webpart with ASP.Net 2.0 and therefore override
    > CreateChildControls(). In CreateChildControls() I create dynamically a
    > menu with items (and sub items) from a database. Let's say after the
    > first loading I have 5 menu items.
    >
    > My problem: Every time the page is loaded (that means also if a menu
    > item is clicked) the menu items are doubled (I have 10, 15, 20, ...
    > menu items).
    >
    > How can I avoid this???
    >
    > Any help is appreciated!
    > Dorrit
    >
     
    Mark Fitzpatrick, Jan 8, 2007
    #2
    1. Advertising

  3. Guest

    This was it. With the ViewState variable I can avoid the menu being
    populated once more.

    Thanks
    Dorrit

    Mark Fitzpatrick schrieb:

    > There are a number of ways to do this. If the menu items in the db don't
    > change frequently you can simply have a viewstate variable that is set once
    > the menu items are loaded. If the viewstate variable isn't there or is set
    > to true, you will know that the menu has been populated and doesn't need to
    > be re-populated. Of course, the simplest way is to just nuke the contents on
    > each load of the control but that is a performance hit on generation. What
    > you have sounds like it's working well, you just need to prevent it from
    > loading a new set of data every time the control is loaded.
    >
    >
    > --
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Former Microsoft FrontPage MVP 199?-2006
    >
    >
    > <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I develop a sharepoint webpart with ASP.Net 2.0 and therefore override
    > > CreateChildControls(). In CreateChildControls() I create dynamically a
    > > menu with items (and sub items) from a database. Let's say after the
    > > first loading I have 5 menu items.
    > >
    > > My problem: Every time the page is loaded (that means also if a menu
    > > item is clicked) the menu items are doubled (I have 10, 15, 20, ...
    > > menu items).
    > >
    > > How can I avoid this???
    > >
    > > Any help is appreciated!
    > > Dorrit
    > >
     
    , Jan 9, 2007
    #3
    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. Lucas Tam
    Replies:
    1
    Views:
    740
    John Saunders
    Aug 17, 2003
  2. popman

    CreateChildControls problem

    popman, May 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    495
    John Saunders
    May 14, 2004
  3. Aren Cambre

    Control.Visible=false affects CreateChildControls

    Aren Cambre, Nov 15, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    256
    Aren Cambre
    Nov 15, 2004
  4. ~~~ .NET Ed ~~~
    Replies:
    1
    Views:
    215
    ~~~ .NET Ed ~~~
    Mar 25, 2005
  5. ~~~ .NET Ed ~~~
    Replies:
    3
    Views:
    198
    Teemu Keiski
    Apr 4, 2005
Loading...

Share This Page