Hi guys,
Welcome back to another C# ProTip, Figure 1.
Figure 1. Logo for C # ProTips!!!
One of the best ways to save important informations, such as Database Connection String, in our website, is saving in web.config file. This can be done easily, but some software projects that are written for use of many users, may need an initializing phase in first use and in this phase they will ask users some information such Username, Password, Database Connection String and so on and will set this information for next uses of system. In systems like this, we need save information in files such as xml files (specially web.config) in runtime and programmatically.
In this ProTip we see how it is possible to modify an xml file, such as web.config file, programmatically in C# language ...
A few years ago, i have wrote an article in Farsi in this field (you can read it HERE). The title of that article also is in this field but there I said that, i will write more in this subject, so now new codes:
Figure 2.
In figure 2, we listed a code inside click event of a button with name btnSet. When this button pressed, the entry of connection string in web.config file will change, figure 3.
Figure 3.
Good luck
Oxford Plus Website
Written by: Abdolreza Ghanbari
Views count: 275