Solved

ASP.net Global.aspx

Posted on 2004-03-24
4
1,115 Views
Last Modified: 2008-03-17
I read from the web.config in my global.aspx. How can I get this variable from my form?

protected void Application_Start(Object sender, EventArgs e)
{
   propertyId = ConfigurationSettings.AppSettings.Get("ID");      
}
0
Comment
Question by:jeremiahscott
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:sforcier
ID: 10670143
Have you tried:

propertyId = ConfigurationSettings.AppSettings("ID");
0
 

Author Comment

by:jeremiahscott
ID: 10670285
yea, i call that once when my app starts up in global.aspx. should i just call that each time from my form instead? is it costly to do that?
0
 
LVL 6

Accepted Solution

by:
sforcier earned 100 total points
ID: 10670497
You could do the following:

'in global.asax
protected void Application_Start(Object sender, EventArgs e)
{
   Application["propertyId"] = ConfigurationSettings.AppSettings.Get("ID");    
}

'in any webform
int x = Application["propertyId"]; //Assuming it's an integer, you get the idea

You mention the alternative of loading from the webconfig in the form itself, which is actually what I'd recommend (conditionally). Using application variables uses memory, and unless you're using this propertyId on every web form, you're wasting memory by loading it in an application variable.
0
 

Author Comment

by:jeremiahscott
ID: 10670535
gotcha. thx!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Prevent URL from printing on header 5 65
Import csv files to MS SQL 5 72
Auto Submit on dropdown box 14 49
Query not working correctly? (or how i want it to... 6 48
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now