Here I will explain how to store or retrive value from Web.config file.
Web.config
<pre class="brush:html;first-line:10">
<configuration>
<appSettings>
<add key="Value" value="" />
</appSettings>
</configuration>
</pre>
Save Value in Web.Config
<pre class="brush:html;first-line:10">
Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
configuration.AppSettings.Settings["Value"].Value = "Nikhil Sangani";
configuration.Save();
</pre>
Retrive Value from Web.Config
<pre class="brush:html;first-line:10">
string value = ConfigurationSettings.AppSettings["Value"].ToString();
</pre>
Comments
Post a Comment