Export (0) Print
Expand All

PagesSection.Namespaces Property

Gets a collection of NamespaceInfo objects.

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

<ConfigurationPropertyAttribute("namespaces")> _
Public ReadOnly Property Namespaces As NamespaceCollection

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. 
Dim i As Int16
For i = 0 To pagesSection.Namespaces.Count - 1
  Console.WriteLine( _
   "Namespaces {0}: '{1}'", i, _

' Create a new NamespaceInfo object. 
Dim namespaceInfo As System.Web.Configuration.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.
pagesSection.Namespaces.Add( _
 New System.Web.Configuration.NamespaceInfo( _

' Execute the RemoveAt method.

' Execute the Clear method.

' Execute the Remove method.

' Get the current AutoImportVBNamespace property value.
Console.WriteLine( _
 "Current AutoImportVBNamespace value: '{0}'", _

' Set the AutoImportVBNamespace property to false.
pagesSection.Namespaces.AutoImportVBNamespace = False

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft