Where To Store Commonly Used information

Posted by David Wier on 04/12/10 | Tips and Tricks

Let's say you have a information (a sentence, word or phrase) that you will be using over and over. Yes, you can manually copy/type it in on every ASP.Net page - BUT - an easier way is to store it in the Web.Config file and then refer to it in the code.

In Web.Config, you would add a key to the AppSettings Section:

    <appSettings>

      <add key="MyPhrase" value="Birds fly south in the winter" />

    </appSettings>

Then, in your C# ASP.Net application - just refer to it like this:
lblErrors.Text = ConfigurationSettings.AppSettings.Get("MyWhatever");






























0 Comments

COMMENTS

Name:
URL:
Comment:

Comments are disabled for this article.