PagesSection.Namespaces Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of NamespaceInfo objects.
public:
property System::Web::Configuration::NamespaceCollection ^ Namespaces { System::Web::Configuration::NamespaceCollection ^ get(); };
[System.Configuration.ConfigurationProperty("namespaces")]
public System.Web.Configuration.NamespaceCollection Namespaces { get; }
[<System.Configuration.ConfigurationProperty("namespaces")>]
member this.Namespaces : System.Web.Configuration.NamespaceCollection
Public ReadOnly Property Namespaces As NamespaceCollection
Property Value
A NamespaceCollection of NamespaceInfo objects.
- Attributes
Examples
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;
' Get the AutoImportVBNamespace property.
Console.WriteLine( _
"AutoImportVBNamespace: '{0}'", _
pagesSection.Namespaces.AutoImportVBNamespace)
' 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, _
pagesSection.Namespaces(i).Namespace)
Next
' 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.
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
Remarks
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.
Applies to
See also
Tee yhteistyötä kanssamme GitHubissa
Tämän sisällön lähde on GitHubissa, jossa voit myös luoda ja tarkastella ongelmia ja pull-pyyntöjä. Katso lisätietoja osallistujan oppaasta.