[thelist] (asp.net) application variables

Tab Alleman talleman at Lumpsum.com
Thu Mar 23 09:05:15 CST 2006


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
> Sent: Wednesday, March 22, 2006 9:12 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] (asp.net) application variables
> 
> 
> 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
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tab Alleman
> Sent: March 22, 2006 02:54 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] (asp.net) application variables
> 
> 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
> > [mailto:thelist-bounces at lists.evolt.org]On Behalf Of Robert Vreeland
> > Sent: Wednesday, March 22, 2006 2:40 PM
> > To: thelist at lists.evolt.org
> > Subject: Re: [thelist] (asp.net) application variables
> > 
> > 
> > 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
> > [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tab Alleman
> > Sent: March 22, 2006 02:22 PM
> > To: Evolt Thelist (E-mail)
> > Subject: [thelist] (asp.net) application variables
> > 
> > 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 !
> > 
> > --
> > 
> > * * 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 !
> > 
> -- 
> 
> * * 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 ! 
> 
> -- 
> 
> * * 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