473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with menu control and CreateChildControls

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 '07 #1
2 1598
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
<do********************@communardo.dewrote in message
news:11**********************@s80g2000cwa.googlegr 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

Jan 8 '07 #2
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
<do********************@communardo.dewrote in message
news:11**********************@s80g2000cwa.googlegr 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
Jan 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark | last post by:
Hi, I have created a custom user control that includes a dynamically created drop down list populated with data from a database. The control class contains a BindList routine that is used to...
1
by: dasein fiasco | last post by:
I'm sure this is a design question that is commonly encountered, but I can't find any resources which explain how to solve it. I would deeply appreciate any advice. Basically, when building a...
0
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set...
4
by: Lloyd Dupont | last post by:
The code snippets are below. I write in (C#) a Page object in a control library. I'm using this page as an HtppHandler in a website (which referes the DLL). This page contains 2 panels (one is...
2
by: shapper | last post by:
Hello, I have a master page where my form has the Runat="server". The master page as a control place holder, named "cphContent". Then in a page which inherits from the master page I added a...
0
by: shapper | last post by:
Hello, I want to create an ordered list where each list item can have various controls: <ol> <li>textbox, label, ...</li> ... </ol>
10
by: Allan Ebdrup | last post by:
I have a custom server web control that inserts another custom web server control in a templated child control (a wisard that inserts a header in its wizardstep) Now after switching to design view...
3
by: shapper | last post by:
Hello, I have a custom control named Parent where I used the following: Protected Overrides Sub CreateChildControls() ... MyBase.Controls.Add(MyTextBox) MyBase.CreateChildControls()...
0
by: Bieniu | last post by:
I have DataList control on my own contro land it is bind to SqlDataSource control. My problem is that DataList is getting needed data twice what is for me very strange. I have some code in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.