System.Web.Configuration Namespace
.NET Framework version 2.0
Provides programmatic access to the clientTarget configuration file section. This class cannot be inherited.
The ClientTargetSection class provides a way to programmatically access and modify the clientTarget section of a configuration file.
This type is part of a group that includes the ClientTarget and ClientTargetCollection types.
The ClientTargetSection class contains ClientTarget objects that define pairs of aliases and associated target user agents for which ASP.NET server controls should render content.
NOTE: The ClientTargetSection can read and write information from and to the related section of the configuration file according to the section property AllowDefinition whose value is Everywhere.
This section provides two code examples. The first displays a declarative representation of the ClientTargetSection class and also demonstrates how to declaratively specify values for several properties of the ClientTarget class. The second shows how to obtain the ClientTargetCollection object from the configuration file. You use this object to access the ClientTarget objects it contains.
The following code example shows how to declaratively specify values for several properties of the ClientTarget class.
<clientTarget>
<add alias =
"ie5" userAgent = "Mozilla/4.0 ( compatible;MSIE 5.5;Windows NT 4.0 )" />
<add alias =
"ie4" userAgent = "Mozilla/4.0 ( compatible;MSIE 4.0;Windows NT 4.0 )" />
<add alias =
"uplevel" userAgent = "Mozilla/4.0 ( compatible;MSIE 4.0;Windows NT 4.0 )" />
<add alias = "downlevel" userAgent = "Unknown" />
</clientTarget>
The following code example shows how to obtain the ClientTargetCollection object from the configuration file
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration ( "/aspnetTest" );
// Get the <clientTarget> section.
ClientTargetSection clientTargetSection =
( ClientTargetSection ) configuration.GetSection ( "system.web/clientTarget" );
// Get the client target collection.
ClientTargetCollection clientTargets = clientTargetSection.ClientTargets;
' Get the Web application configuration.
Dim configuration As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration ( "/aspnetTest" )
' Get the <clientTarget> section.
Dim clientTargetSection As ClientTargetSection = _
CType ( configuration.GetSection ( "system.web/clientTarget" ), ClientTargetSection )
' Get the client target collection.
Dim clientTargets As ClientTargetCollection = clientTargetSection.ClientTargets |
|
C# |
VB |
ASP.NET Configuration <clientTarget> Section ClientTarget Class ClientTargetCollection Class