ClientTargetCollection.Add(ClientTarget) Method

Definition

Adds the specified ClientTarget object to the collection.

public:
 void Add(System::Web::Configuration::ClientTarget ^ clientTarget);
public void Add (System.Web.Configuration.ClientTarget clientTarget);
member this.Add : System.Web.Configuration.ClientTarget -> unit
Public Sub Add (clientTarget As ClientTarget)

Parameters

clientTarget
ClientTarget

The ClientTarget to add to the collection.

Examples

The following code example adds a ClientTarget object to the ClientTargetCollection collection.

For information about how to get the collection, see to the code example in the ClientTargetCollection class overview.


// Create a new ClientTarget object.
clientTarget = new ClientTarget(
  "my alias", "My User Agent"); 
  
// Add the clientTarget to 
// the collection.
clientTargets.Add(clientTarget);

// Update the configuration file.
if (!clientTargetSection.IsReadOnly())
  configuration.Save();
' Create a new ClientTarget object.
clientTarget = New ClientTarget( _
"my alias", "My User Agent")

' Add the clientTarget to 
' the collection.
clientTargets.Add(clientTarget)

' Update the configuration file.
If Not clientTargetSection.IsReadOnly() Then
    configuration.Save()
End If

Remarks

Before adding a client target to the collection, you must create a ClientTarget object and initialize its Alias and UserAgent properties.

Applies to

See also