This documentation is archived and is not being maintained.

CatalogPartCollection::Contains Method

Returns a value indicating whether a particular control exists in the collection.

Namespace:  System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

public:
bool Contains(
	CatalogPart^ catalogPart
)

Parameters

catalogPart
Type: System.Web.UI.WebControls.WebParts::CatalogPart

A CatalogPart that is checked to determine whether it is in the collection.

Return Value

Type: System::Boolean
A Boolean value that indicates whether a particular control is in the collection.

The Contains method enables you to determine whether a particular CatalogPart object is part of a CatalogPartCollection object.

The following code example demonstrates how you can determine whether a particular CatalogPart control is a member of a CatalogPartCollection object. For the full code required to run the example, see the Example section of the CatalogPartCollection class overview topic.

The code in the Button1_Click method creates a new CatalogPartCollection object named myParts. The method uses the Contains method to determine whether the PageCatalogPart1 control exists, and if so, retrieves the control and changes a property value.

No code example is currently available or this language may not be supported.

When you load the page in a browser, you can switch the page into catalog mode by selecting Catalog in the Display Mode drop-down list control. Add the custom WebPart control to the page by selecting the check box next to it and clicking Add. Click Close to return the page to browse mode. On the control you just added, if you click the verbs menu (the down arrow that appears in the title bar) and then click Close, the control is removed from the page and added to the PageCatalogPart control. Return the page to catalog mode, and click the Page Catalog link to view the contents of the PageCatalogPart control. Notice that the control you closed has been added to it. Clicking the Display CatalogPart Properties button accesses the CatalogPartCollection object and displays certain properties of the contained CatalogPart controls. Select the check box next to the server control contained in the PageCatalogPart control, click Add to add it back to the page, and then click Close to return the page to browse mode. Click the verbs menu again on the control, and note that now the close verb is gone. It was removed by the code in the Button1_Click method, when it used the Contains method to check for PageCatalogPart1, and then set its AllowClose property to false.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: