I have a few pages that need to use a value in three seperate macro's. The values I have to get programatically. Currently I am actually doing three calls to the same method, which is obviously an incredible waste.
I was thinking of getting the values only once, and in hooking into the Prerender event to add the values to the HttpContext,Items collection.
The thing I haven't yet figured out though is.. how do I get into the Prerender event, as my user controls are being called during the rendering of the page..
Any ideas? Is there maybe an alternative method that I'm missing here?
Are you able to modify the method that you are calling (3 times)? If so, then on first call, add the result to a HttpContext Item, then on subsequent calls check if the HttpContext Item has a value, and return that.
If you can't modify the method ... then how's about writing a wrapper method for it? Which only deals with the caching/HttpContext Item?
Using values across macro's in the same page
I have a few pages that need to use a value in three seperate macro's. The values I have to get programatically. Currently I am actually doing three calls to the same method, which is obviously an incredible waste.
I was thinking of getting the values only once, and in hooking into the Prerender event to add the values to the HttpContext,Items collection.
The thing I haven't yet figured out though is.. how do I get into the Prerender event, as my user controls are being called during the rendering of the page..
Any ideas? Is there maybe an alternative method that I'm missing here?
Sebastiaan,
Are you able to modify the method that you are calling (3 times)? If so, then on first call, add the result to a HttpContext Item, then on subsequent calls check if the HttpContext Item has a value, and return that.
If you can't modify the method ... then how's about writing a wrapper method for it? Which only deals with the caching/HttpContext Item?
Good luck, Lee.
is working on a reply...