[thelist] (asp.net) application variables

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Mar 23 10:30:15 CST 2006


		XML goes into config files.

I would suggest reading the Quickstarts available at www.asp.net , especially the parts about application configuration.

http://www.dotnetjunkies.com/quickstart/aspplus/doc/configoverview.aspx

Cheers,

Peter

				From: "Tab Alleman" talleman at Lumpsum.com

Hmmm.. when I look in my web.config file, I only see what look like xml tags... no code blocks. It's ok to put code blocks in there? I'm scared. : )

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of Robert Vreeland
> 
> Opps, sorry I was in a rush, I just copied and pasted the code.
> 'sqlConnectionString' is set in the web.config file and is a 
> variable local
> to the app; so you would use whichever variable you were 
> looking for. More
> specifically, we had a similar problem of accessing 
> application variables
> hard coded in config files. For better or worst, we only 
> store the initial
> database connection string in the web.config file, the rest 
> are pulled from
> the backend database and brought into memory via a loop. Here 
> is the code
> for that
> while(reader.Read())
> {
> 
> Application[reader["AppVarName"].ToString()] =
> reader["AppVarValue"].ToString();
> }
> reader.Close();
> 
> With the value of AppVarName being the variable name and the value of
> AppVarValue, well, the value :). These application variables 
> we can then
> access through the familiar (again in c#):
> Application["some_variable_name"] 
> 
> Hope that clears up my previous post.
> 
> Robert
> 
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> ] On Behalf Of Tab Alleman
> 
> Hmmm, the error goes away, but the value is empty.
> 
> How and where are you populating "sqlConnectionString"?
> 
> > -----Original Message-----
> > From: thelist-bounces at lists.evolt.org
> > On Behalf Of Robert Vreeland
> > 
> > Not sure about VBScript, but in c# I'm currently using the 
> following 
> > in the aspx page (string 
> > )ConfigurationSettings.AppSettings["sqlConnectionString"]
> > 
> > Hope it helps,
> > Robert
> > 
> > -----Original Message-----
> > From: thelist-bounces at lists.evolt.org
> > On Behalf Of Tab Alleman
> > 
> > I'm having trouble storing and accessing a simple 
> application variable 
> > in asp.net.
> > 
> > In my global.ascx file, I've got this:
> > 
> > Sub Application_Start(ByVal sender As Object, ByVal e As
> > EventArgs)
> > ' Fires when the application is started
> > Application("foo") = "some text"
> > End Sub
> > and then in one of my pages, I've got this:
> > 
> > strFoo = Application("foo")
> > 
> > which produces the error: "Reference to a non-shared 
> member requires 
> > an object reference".
> > 
> > What am I doing wrong? Should I be "NEW"-ing the Application 
> > somewhere?
> > where?
> > --
> > 
> > * * Please support the community that supports you. * * 
> > http://evolt.org/help_support_evolt/
> > 
> > For unsubscribe and other options, including the Tip Harvester and 
> > archives of thelist go to: http://lists.evolt.org Workers 
> of the Web, 
> > evolt !



More information about the thelist mailing list