This section provides two code examples. The first 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.
// Get the Web application configuration.
System.Configuration.Configuration configuration =
// Get the <clientTarget> section.
ClientTargetSection clientTargetSection =
// Get the client target collection.
ClientTargetCollection clientTargets =
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
' Get the <clientTarget> section.
Dim clientTargetSection _
As ClientTargetSection = _
' Get the client target collection.
Dim clientTargets _
As ClientTargetCollection = _
The ClientTarget class refers to elements that are added in the clientTarget section of the configuration file.
The ClientTarget class contains two properties identifying a client browser, also named user agent. One property is the alias associated with the client browser identified by the second property. ASP.NET uses this information to render server controls in a page.
For information about how the user agent or its alias is used programmatically, see the Page.ClientTarget property. For information about how the user agent or its alias is used declaratively, see @ Page.
If the Page.ClientTarget property is not set, the HttpBrowserCapabilities object that is associated with the Page.Request property reflects the capabilities of the client browser. (It reflects the capabilities of the browser type, but not necessarily the settings in a specific instance of that browser.) If the property is set, the client browser detection is disabled and the page uses browser capabilities that are associated with the user agent string that you define. You can set this property to any valid user agent string.