How to make a particular information to be accessible at masterpage, page and usercontrol
I'm fetching some settings out of the database based on a value passed from a query string. Out of these settings, a few will be used in master page, few on my Page and few in my user control (say login control which is a web user control).
I've an entity class MySetting
fo开发者_开发知识库r it and there is a method in my data access layer which returns me an instance of MySetting
when I pass the value I got in query string.
I don't want to fetch settings from the database multiple times for one request. I'm using asp.net web forms with C# and sql server.
Is only an idea, but you can put in on Context (System.Web.HttpContext.Current) collection, it will be available on Master, page and control and it will exist all the request.
But if the data must be available on more than only one request I use session instead.
精彩评论