This documentation is archived and is not being maintained.

PagesSection.Namespaces Property

Gets a collection of NamespaceInfo objects.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public NamespaceCollection Namespaces { get; }

The TagPrefixInfo objects correspond to the @ Import directive on an ASP.NET page. The Import directive allows you to specify namespaces that are automatically imported into all the pages of an application.

The following code example shows how to use the Namespaces property.

// Get the AutoImportVBNamespace property.
Console.WriteLine("AutoImportVBNamespace: '{0}'",

// Set the AutoImportVBNamespace property.
pagesSection.Namespaces.AutoImportVBNamespace = true;

// Get all current Namespaces in the collection. 
for (int i = 0; i < pagesSection.Namespaces.Count; i++)
      "Namespaces {0}: '{1}'", i,

// Create a new NamespaceInfo object.
System.Web.Configuration.NamespaceInfo namespaceInfo =
    new System.Web.Configuration.NamespaceInfo("System");

// Set the Namespace property.
namespaceInfo.Namespace = "System.Collections";

// Execute the Add Method.

// Add a NamespaceInfo object using a constructor.
    new System.Web.Configuration.NamespaceInfo(

// Execute the RemoveAt method.

// Execute the Clear method.

// Execute the Remove method.

// Get the current AutoImportVBNamespace property value.
    "Current AutoImportVBNamespace value: '{0}'",

// Set the AutoImportVBNamespace property to false.
pagesSection.Namespaces.AutoImportVBNamespace = false;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0