C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Modify the web.config's value at runtime


Posted Date: 04 Nov 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: Lakhan PalMember Level: Diamond    
Rating: 1 out of 5Points: 10



This code snippets will describe the way with which we can change the value of key present in the appsetting section of the web.config.

Suppose you have a key named Price as:

<add key="Price" value="5" />

and you want to change this value dynamically.

Code to Change the above Value:
Namespace needs to added for this:

using System.Configuration;
using System.Web.Configuration;



Configuration myconf = WebConfigurationManager.OpenWebConfiguration("~");
myconf.AppSettings.Settings["Price"].Value = txtPrice.Text.Trim();
myconf.Save();

In the above code txtPrice.Text contains the new value for price.

Thanks & Regards
Lakhan Pal Garg



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Web.config  .  Key value  .  Dynamically  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Using class libraries in C#
Previous Resource: Create and Delete Directory in ASP.NET
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use