ConfigurationElement.GetAttributeValue(String) Method

Definition

Returns the value of the specified attribute.

public:
 System::Object ^ GetAttributeValue(System::String ^ attributeName);
public object GetAttributeValue (string attributeName);
member this.GetAttributeValue : string -> obj
Public Function GetAttributeValue (attributeName As String) As Object

Parameters

attributeName
String

The name of the requested attribute.

Returns

An object that represents the requested attribute, if it exists; otherwise, null.

Exceptions

The attributeName parameter is null or empty.

Examples

The following example gets the attribute value.

// Use any of the following lines to retrieve the attribute value.
// attributeBag[ConfigurationDemoGlobals.AttributeName] = "name";
attributeBag[ConfigurationDemoGlobals.AttributeName] =
    moduleproviderelement.GetAttributeValue("name");
// attributeBag[ConfigurationDemoGlobals.AttributeName] =
//    moduleproviderelement["name"];

Remarks

If the name of the requested attribute is not in the value of the RawAttributes property, this method returns null.

You can also get the attribute value by using the Item[] property or the Microsoft.Web.Administration.ConfigurationAttribute.Value property. GetAttributeValue is the preferred method.

Applies to

See also