SiteMapProviderCollection.Add Method

Definition

Adds a site map provider to the SiteMapProviderCollection collection.

Overloads

Add(ProviderBase)

Adds a SiteMapProvider to the provider collection using the Name property as the key.

Add(SiteMapProvider)

Adds a SiteMapProvider object to the provider collection using the Name property as the key.

Add(ProviderBase)

Adds a SiteMapProvider to the provider collection using the Name property as the key.

public:
 override void Add(System::Configuration::Provider::ProviderBase ^ provider);
public override void Add (System.Configuration.Provider.ProviderBase provider);
override this.Add : System.Configuration.Provider.ProviderBase -> unit
Public Overrides Sub Add (provider As ProviderBase)

Parameters

provider
ProviderBase

The SiteMapProvider to add.

Exceptions

provider is not an instance of the SiteMapProvider class.

-or-

A SiteMapProvider with the same name already exists in the SiteMapProviderCollection.

Remarks

The SiteMapProviderCollection object that is returned by the Providers property is read-only. For this reason, you cannot use the Add and AddArray methods to add additional providers programmatically at run time. Therefore, the Add and AddArray methods are used only in scenarios where you manually create site map provider objects and manage them with an instance of the SiteMapProviderCollection class. The Add(ProviderBase) method checks the type of the specified provider, and then calls the Add(SiteMapProvider) method to add it to the collection.

Because the SiteMap class is static, any SiteMapProvider contained in its Providers collection remains for the lifetime of the Web application.

See also

Add(SiteMapProvider)

Adds a SiteMapProvider object to the provider collection using the Name property as the key.

public:
 void Add(System::Web::SiteMapProvider ^ provider);
public void Add (System.Web.SiteMapProvider provider);
override this.Add : System.Web.SiteMapProvider -> unit
Public Sub Add (provider As SiteMapProvider)

Parameters

provider
SiteMapProvider

The SiteMapProvider to add.

Exceptions

provider is null.

A SiteMapProvider with the same name already exists in the SiteMapProviderCollection.

Remarks

The SiteMapProviderCollection object that is returned by the Providers property is read-only. For this reason, you cannot use the Add and AddArray methods to programmatically add additional providers to the SiteMap at run time. Therefore, the Add and AddArray methods are used only in scenarios where you manually create site map provider objects and manage them with an instance of the SiteMapProviderCollection class. Use the Add method when you want to add a single SiteMapProvider to the SiteMapProviderCollection.

Because the SiteMap class is static, any SiteMapProvider contained in its Providers collection remains for the lifetime of the Web application.

See also

Applies to