473,396 Members | 1,724 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,396 software developers and data experts.

Cache Menu

Hello All, I am trying to cache a menu that I dynamically build out and I do
not want to have to build it out each time the page loads. Here is how I am
doing it however, it doesnt work. Can anyone help? TIA

if (Cache["Menu"] == null)

{

THIS IS WHERE I BUILD OUT THE MENU ITEMS

Cache.Insert("Menu",Menu1); **** Menu1 is the menu control in the web page

}

else

{

Menu1 = (Menu)Cache.Get("Menu");

}
Aug 7 '07 #1
4 3127
When you say "it doesn't work", what do you mean? Does the Cache Item get
populated? Have you tried setting a breakpoint on this code and stepping
through it to examine each object on each line to see what the values are?
Maybe your code is throwing an exception - but I don't see any exception
handling code in your sample.

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"MikeB" wrote:
Hello All, I am trying to cache a menu that I dynamically build out and I do
not want to have to build it out each time the page loads. Here is how I am
doing it however, it doesnt work. Can anyone help? TIA

if (Cache["Menu"] == null)

{

THIS IS WHERE I BUILD OUT THE MENU ITEMS

Cache.Insert("Menu",Menu1); **** Menu1 is the menu control in the web page

}

else

{

Menu1 = (Menu)Cache.Get("Menu");

}
Aug 8 '07 #2
Yes, I have stepped through and there is no exception thrown. It just
doen't fill the menu with anything when I set it here:

Menu1 = (Menu)Cache.Get("Menu");
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.comwrote
in message news:08**********************************@microsof t.com...
When you say "it doesn't work", what do you mean? Does the Cache Item get
populated? Have you tried setting a breakpoint on this code and stepping
through it to examine each object on each line to see what the values are?
Maybe your code is throwing an exception - but I don't see any exception
handling code in your sample.

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"MikeB" wrote:
>Hello All, I am trying to cache a menu that I dynamically build out and I
do
not want to have to build it out each time the page loads. Here is how I
am
doing it however, it doesnt work. Can anyone help? TIA

if (Cache["Menu"] == null)

{

THIS IS WHERE I BUILD OUT THE MENU ITEMS

Cache.Insert("Menu",Menu1); **** Menu1 is the menu control in the web
page

}

else

{

Menu1 = (Menu)Cache.Get("Menu");

}

Aug 8 '07 #3
On Aug 8, 9:48 pm, "MikeB" <m...@nospam.comwrote:
Yes, I have stepped through and there is no exception thrown. It just
doen't fill the menu with anything when I set it here:

Menu1 = (Menu)Cache.Get("Menu");

"Peter Bromberg [C# MVP]" <pbromb...@yahoo.yohohhoandabottleofrum.comwrote
in messagenews:08**********************************@m icrosoft.com...
When you say "it doesn't work", what do you mean? Does the Cache Item get
populated? Have you tried setting a breakpoint on this code and stepping
through it to examine each object on each line to see what the values are?
Maybe your code is throwing an exception - but I don't see any exception
handling code in your sample.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com
"MikeB" wrote:
Hello All, I am trying to cache a menu that I dynamically build out and I
do
not want to have to build it out each time the page loads. Here is how I
am
doing it however, it doesnt work. Can anyone help? TIA
if (Cache["Menu"] == null)
{
THIS IS WHERE I BUILD OUT THE MENU ITEMS
Cache.Insert("Menu",Menu1); **** Menu1 is the menu control in the web
page
}
else
{
Menu1 = (Menu)Cache.Get("Menu");
}- Hide quoted text -

- Show quoted text -
Try this

if (Cache["Menu"] == null)
{
Cache.Insert("Menu",Menu1);
}
Menu1 = (Menu)Cache.Get("Menu");

At the first time when cache is empty you didn't populate the menu.

Aug 9 '07 #4
On Aug 9, 9:14 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
Try this

if (Cache["Menu"] == null)
{
Cache.Insert("Menu",Menu1);}

Menu1 = (Menu)Cache.Get("Menu");

At the first time when cache is empty you didn't populate the menu.
I think I was too fast with my answer, because now I see, it seems you
always have "Menu1". Check if Menu1 is not null at Cache.Insert()

Aug 9 '07 #5

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

Similar topics

7
by: moondaddy | last post by:
I have a products catalogue that I'm putting online and there will be between 20 to 50 different pages of products. Each page contains a datagrid of products for a given category. However, the...
1
by: Rahul | last post by:
Hi I have a SQLServerSiteMapProvider code from one of the guru's from microsoft, So i am successfully getting the records in my Menu control which is reffering to SQLServerSIteMapProvider. ...
0
by: Manuzhai | last post by:
Hello there, I have this weird problem with a mod_python application. Recently I installed ElementTree and cElementTree through ez_setup.py, even though they were already installed normally...
1
by: ed.crookshanks | last post by:
Hello All: I just experienced some weird behavior and I wonder (1) if anyone has experienced this, (2) if it is normal, and (3) if I'm interpreting it correctly. Bascially, I was having a...
3
by: poolieweb | last post by:
I have created a custom user control which creates a ASPxMenu ( Same fucntion as standard menu control) from data retreved from a webservice (Reporting Services) which deals with user access. This...
2
by: =?Utf-8?B?c3Bw?= | last post by:
Is it posible to cache an Menu on a MasterPage ? -- Sorin Sandu Romania
0
by: Hypnotik | last post by:
My program is to simulate cache memory. I read in the info from 2 external files, 1) access 2) data in memory. When I read the information in I display the info...and it is all correct. However...
1
by: JX | last post by:
if you cache two usercontrols, and both of which contains either a menu or treeview, then the first time you get the response right, but on second reqeust or any later request where the cached...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.