Writing a custom section in config file
-
I am creating a project. In that I am having a section "Names" which is a customized section. Now based on the data in the database I want to create a key and value pairs in that section. I searched net but they have given the code to write the key value pair in the appsettings but not in the custom section Can any one tell me how to perform it through code? Many thanks in advance.
Best Regards, M. J. Jaya Chitra
-
I am creating a project. In that I am having a section "Names" which is a customized section. Now based on the data in the database I want to create a key and value pairs in that section. I searched net but they have given the code to write the key value pair in the appsettings but not in the custom section Can any one tell me how to perform it through code? Many thanks in advance.
Best Regards, M. J. Jaya Chitra
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
-
I am creating a project. In that I am having a section "Names" which is a customized section. Now based on the data in the database I want to create a key and value pairs in that section. I searched net but they have given the code to write the key value pair in the appsettings but not in the custom section Can any one tell me how to perform it through code? Many thanks in advance.
Best Regards, M. J. Jaya Chitra
You need two pieces ... First, in configSections, tell it there's a new custom section ...
Then add the section ...
-
I am creating a project. In that I am having a section "Names" which is a customized section. Now based on the data in the database I want to create a key and value pairs in that section. I searched net but they have given the code to write the key value pair in the appsettings but not in the custom section Can any one tell me how to perform it through code? Many thanks in advance.
Best Regards, M. J. Jaya Chitra
You need two pieces ... First, in configSections, tell it there's a new custom section ... <configSections> <section name="productCode" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> Then add the section ... <productCode> <add key="CV" value="AIG Commercial Vehicle" /> <add key="CY" value="Axa Private Car" /> <add key="MC" value="AIG Motorcycle (MCD)" /> </productCode>