Rank: Newbie
Joined: 11/14/2008 Posts: 1 Location: United Kingdom
|
Hi guys,
I'm quite new to Umbraco, so please forgive me if I'm missing something obvious. We are currently building a new website in Umbraco, and are using a number of Web User Controls on each page. The problem is that these User Controls all need access to the same data. We are currently retrieving the same data from the DB for each control, which seems inefficient. As far as I've seen, there is no good way of sharing this data between controls, other than using Session Variables (which we don't want to use for obvious reasons). In a classic ASP.NET application, I would have just defined some public properties in the code behind page, and populated them there. Since Umbraco doesn't provide a class for us to modify, I was wondering what the best solution might be? We can add one user control that retrieves the data, but where could we put it so that every control has easy access to it?
~Yan
|
 Rank: Addict
Joined: 7/19/2006 Posts: 670 Location: Preston, UK
|
Yan, Why not create static class with public static properties. The class constructor will get the data once you have it its in memory then access the properties in your usercontrols: Code:
string myprop = Config.someproperty
its how the umbraco config class works. regards Ismail
Level 2 certified. If it aint broke dont fix.
|
 Rank: Aficionado
Joined: 6/5/2008 Posts: 148 Location: United Kingdom
|
alternatively you could use HttpContext.Current.Items[varName] to store data?
Adam Perry ( blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
|