/
CatalogPartCollection.xml
446 lines (378 loc) · 42.9 KB
/
CatalogPartCollection.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<Type Name="CatalogPartCollection" FullName="System.Web.UI.WebControls.WebParts.CatalogPartCollection">
<TypeSignature Language="C#" Value="public sealed class CatalogPartCollection : System.Collections.ReadOnlyCollectionBase" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit CatalogPartCollection extends System.Collections.ReadOnlyCollectionBase" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class CatalogPartCollection
Inherits ReadOnlyCollectionBase" />
<TypeSignature Language="F#" Value="type CatalogPartCollection = class
 inherit ReadOnlyCollectionBase" />
<TypeSignature Language="C++ CLI" Value="public ref class CatalogPartCollection sealed : System::Collections::ReadOnlyCollectionBase" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Collections.ReadOnlyCollectionBase</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Contains a collection of <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls used to provide catalogs of Web server controls that end users can add to a Web page. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class is a read-only collection of <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls, typically used by a <xref:System.Web.UI.WebControls.WebParts.CatalogZoneBase> zone to track the set of <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls contained by the zone.
When a Web Parts page enters catalog mode, the zone creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object consisting of the <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. Each <xref:System.Web.UI.WebControls.WebParts.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 <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> collection of controls for your own programmatic use if, for example, you need to perform some mass operation on a set of <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. Even though the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object is read-only, you can make programmatic changes to the underlying controls referenced in the collection.
## Examples
The following code example demonstrates several uses of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> 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 class for a custom <xref:System.Web.UI.WebControls.WebParts.WebPart> control named `TextDisplayWebPart`, which is referenced in the Web page and is contained in one of the <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls.
- A Web page that references the `TextDisplayWebPart` control, contains a <xref:System.Web.UI.WebControls.WebParts.CatalogZone> control with two of the <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls from the Web Parts control set declared in the zone, and contains event-driven code to create and manipulate a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> 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](https://msdn.microsoft.com/library/24e42f74-82dc-4c13-8574-130398985fc0) 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](https://msdn.microsoft.com/library/6d90782a-a1a4-45a6-b2d4-cf6362b83b08). Note that the control has a property named `ContentText`; this property holds the value that the user enters in the text box.
[!code-csharp[WebParts_CatalogPartCollection_Overview#3](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/textdisplaywebpart.cs#3)]
[!code-vb[WebParts_CatalogPartCollection_Overview#3](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/textdisplaywebpart.vb#3)]
The third part of the code example is the Web page. Notice that the `<asp:catalogzone>` element for the page contains declarations for two <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. These controls become part of a custom <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object that is created when the `Button1_Click` method executes. The <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control contains Web server controls that have been previously closed by a user at run time. Controls in the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control can be added back to a page. The <xref:System.Web.UI.WebControls.WebParts.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.
[!code-aspx-csharp[WebParts_CatalogPartCollection_Overview#1](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#1)]
[!code-aspx-vb[WebParts_CatalogPartCollection_Overview#1](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#1)]
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 <xref:System.Web.UI.WebControls.WebParts.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 <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control. Return the page to catalog mode, and click the **Page Catalog** link to view the contents of the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control. Notice that the control you closed now appears there. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogZoneBase> zone that contains <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls is typically the control that creates a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object, through the <xref:System.Web.UI.WebControls.WebParts.CatalogZoneBase.CreateCatalogParts%2A> method. However, you can also create your own <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object for other programmatic purposes.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CatalogPartCollection ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 CatalogPartCollection();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new, empty instance of the <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor initializes an empty instance of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class. This overload of the constructor is used internally by the <xref:System.Web.UI.WebControls.WebParts.CatalogZone> class in its <xref:System.Web.UI.WebControls.WebParts.CatalogZone.CreateCatalogParts%2A> method to create an empty collection object. The zone then creates instances of all the <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls declared in the child zone template, and uses an internal method of the collection to add them.
You cannot use this overload of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor to create a new instance of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> and add <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls to it. You must use one of the other overloads for the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor instead.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CatalogPartCollection (System.Collections.ICollection catalogParts);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Collections.ICollection catalogParts) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.#ctor(System.Collections.ICollection)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (catalogParts As ICollection)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.WebParts.CatalogPartCollection : System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.CatalogPartCollection" Usage="new System.Web.UI.WebControls.WebParts.CatalogPartCollection catalogParts" />
<MemberSignature Language="C++ CLI" Value="public:
 CatalogPartCollection(System::Collections::ICollection ^ catalogParts);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="catalogParts" Type="System.Collections.ICollection" />
</Parameters>
<Docs>
<param name="catalogParts">An <see cref="T:System.Collections.ICollection" /> of <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" /> class by passing in an <see cref="T:System.Collections.ICollection" /> collection of <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor initializes an instance of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class and passes in a collection of <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. This is one overload of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor that you can use to create a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and add <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls to it.
Although the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> instance created by the constructor is read-only, you can still access the individual <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in the collection programmatically and call their properties and methods.
One common scenario for using this constructor would be if you want to perform some batch operation on an entire set of <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls, such as changing the content, appearance, or position of a related group of items.
## Examples
The following code example demonstrates how you can create a custom <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection>, and perform a batch operation to change the individual <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in the collection even though it is read-only. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class overview topic.
The code in the `Button1_Click` method creates an <xref:System.Collections.ArrayList> object, adds the two <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in the page to the object, and then creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object using the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.%23ctor%2A> constructor. It also demonstrates how you can make batch changes to the underlying <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls, even though the collection itself is read-only. The code loops through the collection, updating the <xref:System.Web.UI.WebControls.WebParts.Part.Description%2A> property of each control.
[!code-csharp[WebParts_CatalogPartCollection_Overview#2](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#2)]
[!code-vb[WebParts_CatalogPartCollection_Overview#2](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#2)]
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. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. Also, if you position your mouse pointer over the title text within the border of the <xref:System.Web.UI.WebControls.WebParts.DeclarativeCatalogPart> control, you can see the new description text that was added to the control when you clicked the button (the description appears in a ToolTip). If you click the **Page Catalog** link to display the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control, you will find that it also has an updated description.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public CatalogPartCollection (System.Web.UI.WebControls.WebParts.CatalogPartCollection existingCatalogParts, System.Collections.ICollection catalogParts);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Web.UI.WebControls.WebParts.CatalogPartCollection existingCatalogParts, class System.Collections.ICollection catalogParts) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.#ctor(System.Web.UI.WebControls.WebParts.CatalogPartCollection,System.Collections.ICollection)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (existingCatalogParts As CatalogPartCollection, catalogParts As ICollection)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.WebParts.CatalogPartCollection : System.Web.UI.WebControls.WebParts.CatalogPartCollection * System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.CatalogPartCollection" Usage="new System.Web.UI.WebControls.WebParts.CatalogPartCollection (existingCatalogParts, catalogParts)" />
<MemberSignature Language="C++ CLI" Value="public:
 CatalogPartCollection(System::Web::UI::WebControls::WebParts::CatalogPartCollection ^ existingCatalogParts, System::Collections::ICollection ^ catalogParts);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="existingCatalogParts" Type="System.Web.UI.WebControls.WebParts.CatalogPartCollection" />
<Parameter Name="catalogParts" Type="System.Collections.ICollection" />
</Parameters>
<Docs>
<param name="existingCatalogParts">An <see cref="T:System.Collections.ICollection" /> of existing <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls in a zone.</param>
<param name="catalogParts">An <see cref="T:System.Collections.ICollection" /> of additional <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" /> class by passing in an <see cref="T:System.Collections.ICollection" /> collection of the existing <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> controls in a zone, and an additional collection of controls.</summary>
<remarks>To be added.</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Contains">
<MemberSignature Language="C#" Value="public bool Contains (System.Web.UI.WebControls.WebParts.CatalogPart catalogPart);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance bool Contains(class System.Web.UI.WebControls.WebParts.CatalogPart catalogPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Contains(System.Web.UI.WebControls.WebParts.CatalogPart)" />
<MemberSignature Language="VB.NET" Value="Public Function Contains (catalogPart As CatalogPart) As Boolean" />
<MemberSignature Language="F#" Value="member this.Contains : System.Web.UI.WebControls.WebParts.CatalogPart -> bool" Usage="catalogPartCollection.Contains catalogPart" />
<MemberSignature Language="C++ CLI" Value="public:
 bool Contains(System::Web::UI::WebControls::WebParts::CatalogPart ^ catalogPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="catalogPart" Type="System.Web.UI.WebControls.WebParts.CatalogPart" />
</Parameters>
<Docs>
<param name="catalogPart">A <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> that is checked to determine whether it is in the collection.</param>
<summary>Returns a value indicating whether a particular control exists in the collection.</summary>
<returns>A Boolean value that indicates whether a particular control is in the collection.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Contains%2A> method enables you to determine whether a particular <xref:System.Web.UI.WebControls.WebParts.CatalogPart> object is part of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object.
## Examples
The following code example demonstrates how you can determine whether a particular <xref:System.Web.UI.WebControls.WebParts.CatalogPart> control is a member of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class overview topic.
The code in the `Button1_Click` method creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object named `myParts`. The method uses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Contains%2A> method to determine whether the `PageCatalogPart1` control exists, and if so, retrieves the control and changes a property value.
[!code-csharp[WebParts_CatalogPartCollection_Overview#2](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#2)]
[!code-vb[WebParts_CatalogPartCollection_Overview#2](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#2)]
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 <xref:System.Web.UI.WebControls.WebParts.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 <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control. Return the page to catalog mode, and click the **Page Catalog** link to view the contents of the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control. Notice that the control you closed has been added to it. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. Select the check box next to the server control contained in the <xref:System.Web.UI.WebControls.WebParts.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 <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Contains%2A> method to check for `PageCatalogPart1`, and then set its <xref:System.Web.UI.WebControls.WebParts.WebPart.AllowClose%2A> property to `false`.
]]></format>
</remarks>
<altmember cref="M:System.Collections.IList.Contains(System.Object)" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="CopyTo">
<MemberSignature Language="C#" Value="public void CopyTo (System.Web.UI.WebControls.WebParts.CatalogPart[] array, int index);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void CopyTo(class System.Web.UI.WebControls.WebParts.CatalogPart[] array, int32 index) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.CopyTo(System.Web.UI.WebControls.WebParts.CatalogPart[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub CopyTo (array As CatalogPart(), index As Integer)" />
<MemberSignature Language="F#" Value="member this.CopyTo : System.Web.UI.WebControls.WebParts.CatalogPart[] * int -> unit" Usage="catalogPartCollection.CopyTo (array, index)" />
<MemberSignature Language="C++ CLI" Value="public:
 void CopyTo(cli::array <System::Web::UI::WebControls::WebParts::CatalogPart ^> ^ array, int index);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="array" Type="System.Web.UI.WebControls.WebParts.CatalogPart[]" />
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="array">An array of <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> objects to contain the copied collection.</param>
<param name="index">The starting point in the array at which to place the collection contents.</param>
<summary>Copies the collection to an array of <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.CopyTo%2A> method is useful when you want to assemble a custom array that can contain the <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object, or a subset of those controls.
]]></format>
</remarks>
<altmember cref="M:System.Collections.ICollection.CopyTo(System.Array,System.Int32)" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Empty">
<MemberSignature Language="C#" Value="public static readonly System.Web.UI.WebControls.WebParts.CatalogPartCollection Empty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Web.UI.WebControls.WebParts.CatalogPartCollection Empty" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Empty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Empty As CatalogPartCollection " />
<MemberSignature Language="F#" Value=" staticval mutable Empty : System.Web.UI.WebControls.WebParts.CatalogPartCollection" Usage="System.Web.UI.WebControls.WebParts.CatalogPartCollection.Empty" />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Web::UI::WebControls::WebParts::CatalogPartCollection ^ Empty;" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.CatalogPartCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>References a static, read-only, empty instance of the collection.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A static, read-only, empty instance of <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> reduces memory usage in cases where you want an empty collection instance to return the proper object type from a method or to compare the instance with another object, but you do not need to add members to the instance.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="IndexOf">
<MemberSignature Language="C#" Value="public int IndexOf (System.Web.UI.WebControls.WebParts.CatalogPart catalogPart);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance int32 IndexOf(class System.Web.UI.WebControls.WebParts.CatalogPart catalogPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.CatalogPartCollection.IndexOf(System.Web.UI.WebControls.WebParts.CatalogPart)" />
<MemberSignature Language="VB.NET" Value="Public Function IndexOf (catalogPart As CatalogPart) As Integer" />
<MemberSignature Language="F#" Value="member this.IndexOf : System.Web.UI.WebControls.WebParts.CatalogPart -> int" Usage="catalogPartCollection.IndexOf catalogPart" />
<MemberSignature Language="C++ CLI" Value="public:
 int IndexOf(System::Web::UI::WebControls::WebParts::CatalogPart ^ catalogPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="catalogPart" Type="System.Web.UI.WebControls.WebParts.CatalogPart" />
</Parameters>
<Docs>
<param name="catalogPart">A <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> that is a member of the collection.</param>
<summary>Returns the position of a particular member of the collection.</summary>
<returns>A <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> that is a member of the <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPartCollection" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.IndexOf%2A> method is useful if you have multiple <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls on a Web Parts page, and you need to locate a particular control in the collection.
## Examples
The following code example demonstrates how you can determine the position of a member of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> collection by using its <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.IndexOf%2A> property. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class overview topic.
The code in the `Button1_Click` method creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object named `myParts`. The method uses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.IndexOf%2A> property to retrieve the position of the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control, and then changes a property value on the control.
[!code-csharp[WebParts_CatalogPartCollection_Overview#2](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#2)]
[!code-vb[WebParts_CatalogPartCollection_Overview#2](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#2)]
After 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. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. Click the **Page Catalog** link to display the contents of the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control. Note that it has only a title and no border, because its <xref:System.Web.UI.WebControls.WebParts.WebPart.ChromeType%2A> property value was changed to <xref:System.Web.UI.WebControls.WebParts.PartChromeType.TitleOnly> in the code that used the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.IndexOf%2A> property to retrieve the control.
]]></format>
</remarks>
<altmember cref="M:System.Collections.IList.IndexOf(System.Object)" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<MemberGroup MemberName="Item">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Returns a specific member of the collection according to its position or a unique identifier.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public System.Web.UI.WebControls.WebParts.CatalogPart this[int index] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.WebParts.CatalogPart Item(int32)" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Default Public ReadOnly Property Item(index As Integer) As CatalogPart" />
<MemberSignature Language="F#" Value="member this.Item(int) : System.Web.UI.WebControls.WebParts.CatalogPart" Usage="System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::UI::WebControls::WebParts::CatalogPart ^ default[int] { System::Web::UI::WebControls::WebParts::CatalogPart ^ get(int index); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.CatalogPart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="index">The index of a particular <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> in the collection.</param>
<summary>Gets or sets a member of the collection, based on its position in the collection.</summary>
<value>A <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> at the specified index in the collection.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer allows you to access the underlying <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object by index, and change their property values or call methods.
## Examples
The following code example demonstrates how you can access a member of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object using its index. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class overview topic.
The code in the `Button1_Click` method creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object named `myParts`. Note that the method uses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer to retrieve information from the first member of the collection.
[!code-csharp[WebParts_CatalogPartCollection_Overview#2](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#2)]
[!code-vb[WebParts_CatalogPartCollection_Overview#2](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#2)]
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. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. The count of available server controls within the <xref:System.Web.UI.WebControls.WebParts.PageCatalogPart> control is obtained by using the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer in the `Button1_Click` method.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public System.Web.UI.WebControls.WebParts.CatalogPart this[string id] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.WebParts.CatalogPart Item(string)" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item(System.String)" />
<MemberSignature Language="VB.NET" Value="Default Public ReadOnly Property Item(id As String) As CatalogPart" />
<MemberSignature Language="F#" Value="member this.Item(string) : System.Web.UI.WebControls.WebParts.CatalogPart" Usage="System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::UI::WebControls::WebParts::CatalogPart ^ default[System::String ^] { System::Web::UI::WebControls::WebParts::CatalogPart ^ get(System::String ^ id); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.CatalogPart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="id" Type="System.String" />
</Parameters>
<Docs>
<param name="id">The unique identifier for a particular <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> in a collection.</param>
<summary>Returns a member of the collection based on a unique string identifier.</summary>
<value>The first <see cref="T:System.Web.UI.WebControls.WebParts.CatalogPart" /> in the collection whose ID equals the value of <paramref name="id" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer allows you to access the underlying <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls in a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object by use of a string identifier. Although the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object is read-only, you can change the property values or call methods on the underlying controls accessed by the indexer.
## Examples
The following code example demonstrates how you can access a member of a <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object using its string ID value. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> class overview topic.
The code in the `Button1_Click` method creates a new <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object named `myParts`. The method uses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer to retrieve information about the <xref:System.Web.UI.WebControls.WebParts.DeclarativeCatalogPart> control, which is the second member of the collection.
[!code-csharp[WebParts_CatalogPartCollection_Overview#2](~/snippets/csharp/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/CS/catalogpartcollectioncs.aspx#2)]
[!code-vb[WebParts_CatalogPartCollection_Overview#2](~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_CatalogPartCollection_Overview/VB/catalogpartcollectionvb.aspx#2)]
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. Clicking the **Display CatalogPart Properties** button accesses the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection> object and displays certain properties of the contained <xref:System.Web.UI.WebControls.WebParts.CatalogPart> controls. The count of available server controls within the <xref:System.Web.UI.WebControls.WebParts.DeclarativeCatalogPart> control is obtained by using the <xref:System.Web.UI.WebControls.WebParts.CatalogPartCollection.Item%2A> indexer in the `Button1_Click` method.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
</Members>
</Type>