Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PagesSection.Namespaces Property

Gets a collection of NamespaceInfo objects.

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

public NamespaceCollection Namespaces { get; }
/** @property */
public NamespaceCollection get_Namespaces ()

public function get Namespaces () : NamespaceCollection

Not applicable.

Property Value

A NamespaceCollection of NamespaceInfo objects.

The TagPrefixInfo objects correspond to the Import directive (<%@ Import %>) 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}'",
    pagesSection.Namespaces.AutoImportVBNamespace.ToString());

// Set the AutoImportVBNamespace property.
pagesSection.Namespaces.AutoImportVBNamespace = true;
 
// Get all current Namespaces in the collection.
for (int i = 0; i < pagesSection.Namespaces.Count; i++)
{
  Console.WriteLine(
      "Namespaces {0}: '{1}'", i,
      pagesSection.Namespaces[i].Namespace);
}

// 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.
pagesSection.Namespaces.Add(namespaceInfo);

// Add a NamespaceInfo object using a constructor.
pagesSection.Namespaces.Add(
    new System.Web.Configuration.NamespaceInfo(
    "System.Collections.Specialized"));

// Execute the RemoveAt method.
pagesSection.Namespaces.RemoveAt(0);

// Execute the Clear method.
pagesSection.Namespaces.Clear();

// Execute the Remove method.
pagesSection.Namespaces.Remove("System.Collections");

// Get the current AutoImportVBNamespace property value.
Console.WriteLine(
    "Current AutoImportVBNamespace value: '{0}'",
    pagesSection.Namespaces.AutoImportVBNamespace);

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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.