Contains a collection of CatalogPart controls used to provide catalogs of Web server controls that end users can add to a Web page. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|CatalogPartCollection()||Initializes a new, empty instance of the class.|
|CatalogPartCollection(ICollection)||Initializes a new instance of the class by passing in an ICollection collection of CatalogPart controls.|
|CatalogPartCollection(CatalogPartCollection, ICollection)||Initializes a new instance of the class by passing in an ICollection collection of the existing CatalogPart controls in a zone, and an additional collection of controls.|
|Count||Gets the number of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)|
|Item[Int32]||Gets or sets a member of the collection, based on its position in the collection.|
|Item[String]||Returns a member of the collection based on a unique string identifier.|
|Contains||Returns a value indicating whether a particular control exists in the collection.|
|CopyTo||Copies the collection to an array of CatalogPart objects.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetEnumerator||Returns an enumerator that iterates through the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|IndexOf||Returns the position of a particular member of the collection.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|ICollection::CopyTo||Copies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ReadOnlyCollectionBase.)|
|ICollection::IsSynchronized||Gets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe). (Inherited from ReadOnlyCollectionBase.)|
|ICollection::SyncRoot||Gets an object that can be used to synchronize access to a ReadOnlyCollectionBase object. (Inherited from ReadOnlyCollectionBase.)|
When a Web Parts page enters catalog mode, the zone creates a new object consisting of the CatalogPart controls. Each CatalogPart control in the collection can contain references to zero or more Web server controls, which are displayed in the form of a catalog of available server controls.
You can create a collection of controls for your own programmatic use if, for example, you need to perform some mass operation on a set of CatalogPart controls. Even though the object is read-only, you can make programmatic changes to the underlying controls referenced in the collection.
The following code example demonstrates several uses of the class. There are four parts to this code example:
A user control that enables you to change display modes on a Web Parts page.
A Web page that references the TextDisplayWebPart control, contains a CatalogZone control with two of the CatalogPart controls from the Web Parts control set declared in the zone, and contains event-driven code to create and manipulate a object.
An explanation of how the code example works when you load it in a browser.
The first part of the code example is the user control. The source code for the user control comes from another topic. For this code example to work, you need to obtain the .ascx file for the user control from the Walkthrough: Changing Display Modes on a Web Parts Page topic, and place the file in the same folder as the .aspx page in this code example.
The second part of the code example is the TextDisplayWebPart control. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. For a walkthrough that demonstrates both methods of compiling, see Walkthrough: Developing and Using a Custom Web Server Control. Note that the control has a property named ContentText; this property holds the value that the user enters in the text box.
The third part of the code example is the Web page. Notice that the <asp:catalogzone> element for the page contains declarations for two CatalogPart controls. These controls become part of a custom object that is created when the Button1_Click method executes. The PageCatalogPart control contains Web server controls that have been previously closed by a user at run time. Controls in the PageCatalogPart control can be added back to a page. The DeclarativeCatalogPart control contains a declaration of the custom TextDisplayWebPart control. When the page is in catalog mode, a user can add the TextDisplayWebPart control to the page so that it can be used in normal browse mode.
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. You can 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 now appears there. Clicking the Display CatalogPart Properties button accesses the object and displays certain properties of the contained CatalogPart controls.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.