.NET Framework Class Library
ConfigurationAttribute..::.Value Property

Gets the value of the configuration attribute.

Namespace:  Microsoft.Web.Administration
Assembly:  Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)
Syntax

Visual Basic (Declaration)
Public Property Value As Object
    Get
    Set
Visual Basic (Usage)
Dim instance As ConfigurationAttribute
Dim value As Object

value = instance.Value

instance.Value = value
C#
public Object Value { get; set; }
Visual C++
public:
property Object^ Value {
    Object^ get ();
    void set (Object^ value);
}
JScript
function get Value () : Object
function set Value (value : Object)

Property Value

Type: System..::.Object
The value of the configuration attribute.
Remarks

Configuration attribute values are not strongly typed. The value of this property must be explicitly cast to the correct type.

Examples

The following example gets the value of the Value property for each of the configuration attributes. This code example is part of a larger example provided for the ConfigurationAttribute class.

Visual Basic
Dim configAttributeCollection As ConfigurationAttributeCollection = manager.GetApplicationHostConfiguration.GetSection("system.web/anonymousIdentification").Attributes
Console.WriteLine(("There are " & configAttributeCollection.Count.ToString & " Configuration attributes."))
Dim attribute As ConfigurationAttribute = configAttributeCollection.Item(1)
Console.WriteLine(("metadata: " & attribute.GetMetadata("encryptionProvider")))
Dim configAttribute As ConfigurationAttribute
'' Display each configuration attribute with properties and metadata.
For Each configAttribute In configAttributeCollection
    Console.WriteLine(ChrW(9) & "{0}" & ChrW(9) & "{1}" & ChrW(9) & "{2}" & ChrW(9) & "{3}", New Object() {configAttribute.Name, configAttribute.Value, configAttribute.IsProtected, configAttribute.GetMetadata("encryptionProvider")})
Next
C#
// Get the attributes again, after the commit changes.
Configuration config2 = manager.GetApplicationHostConfiguration();
configSection = config2.GetSection("system.web/anonymousIdentification");
configAttributeCollection = configSection.Attributes;
Console.WriteLine("There are " +
    configAttributeCollection.Count.ToString() +
    " Configuration attributes.");
attribute = configAttributeCollection[1];
Console.WriteLine("metadata: " +
    attribute.GetMetadata("encryptionProvider"));
// Display each configuration attribute with properties and metadata.
foreach (ConfigurationAttribute configAttribute in configAttributeCollection)
{
    Console.WriteLine("\t{0}\t{1}\t{2}\t{3}",
         configAttribute.Name,
         configAttribute.Value,
         configAttribute.IsProtected,
         configAttribute.GetMetadata("encryptionProvider"));
}
See Also

Reference

Tags :


Page view tracker