|
|
|
start date: Tue, 7 Aug 2007 16:29:36 -0400,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
MikeB
|
|
2
Peter Bromberg [C# MVP]
|
|
3
MikeB
|
|
4
Alexey Smirnov
|
|
5
Alexey Smirnov
|
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");
}
Date:Tue, 7 Aug 2007 16:29:36 -0400
Author:
|
RE: Cache Menu
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");
>
> }
>
>
>
Date:Wed, 8 Aug 2007 04:48:07 -0700
Author:
|
Re: Cache Menu
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]" wrote
in message news:0837D69B-44A6-4CE6-AC42-54C0B56F90A4@microsoft.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");
>>
>> }
>>
>>
>>
Date:Wed, 8 Aug 2007 15:48:46 -0400
Author:
|
Re: Cache Menu
On Aug 8, 9:48 pm, "MikeB" wrote:
> 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]" wrote
> in messagenews:0837D69B-44A6-4CE6-AC42-54C0B56F90A4@microsoft.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.
Date:Thu, 09 Aug 2007 07:14:22 -0000
Author:
|
Re: Cache Menu
On Aug 9, 9:14 am, Alexey Smirnov wrote:
> 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()
Date:Thu, 09 Aug 2007 07:19:34 -0000
Author:
|
|
|