Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you declare global constans?

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
CA
Hi again, where abouts would I declare all my global constants? i.e: I have some directory paths I want to be in one place only for the project so I don't have to search every project file when I deploy this web...

I want to do this in a global context:

Public Const PASSWORD_FILE = "C:\somedir\PasswordFile.xml"

Simple...Right? Chris says: "It's time for a beer."
 
Should just be in the web.config file. You can use and make keys they are called to hold strings for creating dynamic properties for controls

</system.web>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key=&quot;settingName&quot; value=&quot;settingValue&quot;/> -->
<add key=&quot;SqlConnection1.ConnectionString&quot; value=&quot;data source=Mark;initial catalog=RoamingForest;user id=RF;password=password;packet size=4096&quot; />
</appSettings>


I have used this to make my connection string dynamic for any object that i need.

The other place is in global.asax under the application start sub.


Mark says mmmm beeeeeeeeeer


HTH [peace]
 
You could also stick it in a module like old school vb6.0, but it really is a better idea to do it in the web.config. That way you always know where your constants are instead of hunting for them through a pile of .vb files.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top