Wednesday, April 9, 2008

How To Create User Defined Tag In WebConfig

WebConfig
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="YourTagName" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.3300.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
.
.
.
.
</configSections>
<appSettings>
.
.
.
</appSettings>
<YourTagName>
<add key="YourKeyName1" value="Xploredotnet"/>
<add key="YourKeyName2" value="adminpwd"/>
</YourTagName>

.
.
.
.
.
</configuration>



Code Behind
This is one of the way to access Custom Tag

string AdUrs,AdPwd;
AdUrs = ((System.Collections.Specialized.NameValueCollection)ConfigurationManager.GetSection("YourTagName"))["YourKeyName1"] +string.Empty;
AdPwd = ((System.Collections.Specialized.NameValueCollection)ConfigurationManager.GetSection("YourTagName"))["YourKeyName2"] + string.Empty;


No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.