advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 1.4/5 | Rate this item | 5 users have rated this item.
Expertise: Intermediate
Language: XML, ASP
August 6, 2003
Use XML to Store Your App Settings in ASP
XML provides many opportunities to share and store data. One of the most common and simple uses of XML is to use it to store data used by your application.

Every application uses data. The traditional way to store this data was in INI files. Then came registries. Now, more and more applications use XML files to store their app settings.

With ASP, you typically store such data in the Application.Contents collection. Oftentimes, these are hardcoded into the Application_OnStart event. Rather than hardcoding these variables, you can store them in an XML file. Simply access the XML file in the Application_OnStart event to initialize the application variables. The XML file may look like this:


<Properties>
<Property>
<Name>PropName1</Name>
<Value>PropValue1</Value>
</Property>
<Property>
<Name>PropName2</Name>
<Value>PropValue2</Value>
</Property>
</Properties>
You can also write the code to access the XML file and return an array with prop names and values in a COM component. This allows you to change any value in XML when the app is running and refresh the Application.Contents collection without having to restart the app to run the OnStart event. Simply call the Component's method to refresh your variables!

ASP.NET uses a similar concept with a pre-created file called web.config for each ASP.NET application. This file simple XML file has a similar structure.

Jatin Shah
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs