Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




How can we add our custom tag in web.config

We can add our custom tags in web config. I got solution from internet with below example. Please check below:

				
<configuration>
<configSections>
<sectionGroup name="Test">
<section name="pageStyle" type="Xpode.MyName, MyStyle" />
</sectionGroup>
</configSections>
<devhood>
<pageStyle backColour="navy" />
</devhood>
</configuration>

namespace Xpode
{
internal class MyName : IConfigurationSectionHandler
{
public virtual object Create(Object parent, Object context, XmlNode node)
{
MyStyle config = new MyStyle((PageStyle)parent);
config.LoadValuesFromConfigurationXml(node);
return config;
}
}

public class MyStyle
{
string _backColour;

internal MyStyle(PageStyle parent)
{
if (parent != null)
_backColour = parent._backColour;
}

internal void LoadValuesFromConfigurationXml(XmlNode node)
{
XmlAttributeCollection attribCol = node.Attributes;
_backColour = attribCol["backColour"].Value;
}

public string BackColour
{
get
{
return _backColour;
}
}
}
}

Share this article   |    Print    |    Article read by 2698 times
Author:
Guest
Guest user is that user who have done some activity on website without login. Activity contains commenting on any article, uploading an image on website etc.
Related Articles:
Related Interview Questions: