Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with menu control and CreateChildControls

Reply
Thread Tools

Problem with menu control and CreateChildControls

 
 
dorrit.Riemenschneider@communardo.de
Guest
Posts: n/a
 
      01-08-2007
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

 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      01-08-2007
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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>



 
Reply With Quote
 
 
 
 
dorrit.Riemenschneider@communardo.de
Guest
Posts: n/a
 
      01-09-2007
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
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > 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
> >


 
Reply With Quote
 
 
 
Reply

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
Why is this.Page NOT initialized when a composite control's CreateChildControls is being executed ~~~ .NET Ed ~~~ ASP .Net Building Controls 3 04-04-2005 01:26 PM
Why is CreateChildControls called when a dropdownlist (of a composite control) selected index has changed ~~~ .NET Ed ~~~ ASP .Net Building Controls 1 03-25-2005 12:34 AM
Control.Visible=false affects CreateChildControls Aren Cambre ASP .Net Building Controls 0 11-15-2004 08:35 PM
CreateChildControls problem popman ASP .Net 1 05-14-2004 09:06 PM
Capturing Events before CreateChildControls in Composite Control Lucas Tam ASP .Net 1 08-17-2003 05:02 PM



Advertisments