i m using a third party upload control and there r few settings in web.config
<uploadSettings allowedFileExtensions=".pdf,.xls,.doc,.zip,.rar,.jpg" scriptPath="upload_scripts" imagePath="" cssPath="upload_styles" enableManualProcessing="true" showProgressBar="true" showCancelButton="true"/>
now i want to change these settings from code behind e.g i want to make showcancelbutton="false"
how do i do that
Since it's a web application you want to change I'd go with the WebConfigurationManager.
If the configuration value you are about to change is in a separate section you need to get that section first:
var myConfiguration = (Configuration)WebConfigurationManager.OpenWebConfiguration("~");
var section = (MySectionTypeHere)myConfiguration.GetSection("system.web/mySectionName");
//Change your settings here
myConfiguration.Save();
Keep in mind that the web application will be restarted each time you change the web.config.
An article explaining it more in detail is available here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With