ASP.NET 2.0 - Application level Collection - HELP !

G

Guest

Hello!

I have (hopefully) a very simple question. I need to define an application
level collection variable for an ASP.NET 2.0 web application, and fill it
with data when the application starts.

The collection needs to be defined and filled with data on the
"Application_Start()" event, which is in the Global.asax file, however, I'm
having trouble deciding where the collection needs to be declared in order
for it to be accessed globally across all pages.

In case it's of any use, the collection is going to hold all the dialogue
for a website.
 
G

Guest

Ok, I think I may have found a solution:

In the Application_Start section of the global.asax, I create a collection
called colDialog, fill it with data, and then add it into the application
object by using this syntax:

Application.Add("DIALOG", colDialog)

Then, if I want to reference this collection within an aspx.vb file, I use
this syntax:

Dim colDialog As Collection = Application("DIALOG")


Is this a good way of acheiving what i'm trying to achieve? One annoying
factor in doing this seems to be that I can't write one global function to
retrieve this data whenever I want to, I'll need to write a function to
retrieve the dialogue inside every aspx.vb page, because i can't seem to be
able to create a global function from within a .VB file held in VB2005's new
"app_code" folder.

Plus also, I don't think that files in the "app_code" folder can access the
application object. I've played around with importing different web
references but that didn't help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top