ConfigurationElement.SetAttributeValue Method (String, Object)


Sets the value of the specified attribute.

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

public void SetAttributeValue(
	string attributeName,
	object value


Type: System.String

The name of the attribute to change.

Type: System.Object

The new value of the attribute.

Exception Condition

The attributeName parameter is null or empty.

This method sets the attribute value and writes it to the Administration.config file. The Administration.config file is not modified until the CommitChanges method is called.

You can also set the attribute value by using the Item or Value properties. For best system performance, you should use the SetAttributeValue method.

The following example modifies the element with the name "TestDemo". The value is modified to "TestDemo(modified)".

Return to top