/
WebPartChrome.xml
588 lines (505 loc) · 59.9 KB
/
WebPartChrome.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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<Type Name="WebPartChrome" FullName="System.Web.UI.WebControls.WebParts.WebPartChrome">
<TypeSignature Language="C#" Value="public class WebPartChrome" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit WebPartChrome extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.WebParts.WebPartChrome" />
<TypeSignature Language="VB.NET" Value="Public Class WebPartChrome" />
<TypeSignature Language="F#" Value="type WebPartChrome = class" />
<TypeSignature Language="C++ CLI" Value="public ref class WebPartChrome" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Enables developers to override the rendering for only the selected sections of <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> or server controls in a <see cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" /> zone.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Web Parts chrome refers to the peripheral user interface (UI) elements that frame each <xref:System.Web.UI.WebControls.WebParts.WebPart> control or server control contained in a <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone. The chrome for a control includes its border, its title bar, and the icons, title text, and verbs menu that appear within the title bar. The appearance of the chrome is set at the zone level, and applies to all the server controls in the zone.
The Web Parts control set uses the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class to render the chrome for <xref:System.Web.UI.WebControls.WebParts.WebPart> controls. Additionally, this class provides a way for developers to customize the rendering of any individual section (such as the header or footer) of the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls in a <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone without having to handle all the rendering for those controls. For example, you can override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method to customize some specific style attributes applied to the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone, but you can rely on the default rendering to handle the rest.
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class contains several important methods that are useful when you want to override the rendering of <xref:System.Web.UI.WebControls.WebParts.WebPart> controls. One is the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method, which enables you to change the style attributes of the <xref:System.Web.UI.WebControls.Style> object associated with the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object used to render a control. Another is the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.%23ctor%2A> constructor, which you use when you override the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.CreateWebPartChrome%2A> method in a custom <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> class to create an instance of your custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object. Another useful method is the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents%2A> method, which you can use to control the rendering of the content area of controls in a zone (as opposed to chrome elements such as headers, footers, and title bars). The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method enables you to exclude certain verbs from being rendered, if for some reason you do not want users to see those verbs in the UI. Finally, if you want complete programmatic control over all aspects of rendering the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls, you can override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderWebPart%2A> method.
Several properties of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class are also useful. The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone%2A> and <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager%2A> properties provide references to the zone associated with the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object and the current <xref:System.Web.UI.WebControls.WebParts.WebPartManager> instance, respectively.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class to override the default rendering of <xref:System.Web.UI.WebControls.WebParts.WebPart> controls in a <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone.
The code example has four parts:
- A user control that enables you to change display modes on a Web Parts page.
- A Web page that hosts all the controls in the example.
- A class that contains the source code for a custom <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone and a <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class.
- An explanation of how the example works.
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 example is the Web page. Note that there is a `Register` directive near the top of the file to register the compiled component and a tag prefix. Also note that the page references the custom zone using the element `<aspSample:MyZone>` and includes several standard ASP.NET server controls within the zone. The server controls do not implement any actual functionality; they are used here only to illustrate how the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class features apply to rendering zones. Note that these server controls, though they are not actual <xref:System.Web.UI.WebControls.WebParts.WebPart> controls, are each automatically wrapped (by ASP.NET) with a <xref:System.Web.UI.WebControls.WebParts.GenericWebPart> object at run time, so they will have the same functionality as <xref:System.Web.UI.WebControls.WebParts.WebPart> controls.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/webpartchromecs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/webpartchromevb.aspx" id="Snippet1":::
The third part of the code example is the source for the custom <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone and a <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class. In the constructor for the custom zone class, the code checks the `MyZone.RenderVerbsInMenu` property. If the value is `true`, verbs are rendered in a menu for each of the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls in the zone. This is the normal, default behavior in the Web Parts controls set. If the `MyZone.RenderVerbsInMenu` property value is `false`, which is the default in this custom zone, the verbs are rendered individually as links in the title bar of each control. Notice that in the Web page code where the `<aspSample:MyZone>` element is declared, there is a `RenderVerbsInMenu` attribute set to `true`, so that the verbs will appear in menus on the controls. To experiment with this feature, you can set the declarative `RenderVerbsInMenu` attribute to `false`, and note how the verbs are rendered as links.
The custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overrides the rendering on several methods, and the custom zone creates an instance of the `MyWebPartChrome` class in its <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.CreateWebPartChrome%2A> method. This applies the custom rendering to the page. 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).
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet2":::
When you load the Web page in a browser, you can see how the various stylistic and other rendering customizations made in the source code of the `MyWebPartChrome` class appear on the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls rendered in the zone.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>Inherit from the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> class when you want to override the default rendering of certain sections of <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> or server controls. You can optionally override the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle(System.Web.UI.WebControls.WebParts.WebPart,System.Web.UI.WebControls.WebParts.PartChromeType)" /> method, the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs(System.Web.UI.WebControls.WebParts.WebPart)" /> method, and especially the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" /> or <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderWebPart(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" /> methods, to customize the rendering. To use your custom <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> class for the <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> controls in a zone, develop a custom zone derived from the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" /> class, and override its <see cref="M:System.Web.UI.WebControls.WebParts.WebPartZoneBase.CreateWebPartChrome" /> method. For details on how to use a child <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> object in a zone, see the Example section.</para>
</block>
<altmember cref="T:System.Web.UI.WebControls.WebParts.WebPart" />
<altmember cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/k3w2y2tf(v=vs.100)">Web Parts Control Set Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public WebPartChrome (System.Web.UI.WebControls.WebParts.WebPartZoneBase zone, System.Web.UI.WebControls.WebParts.WebPartManager manager);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Web.UI.WebControls.WebParts.WebPartZoneBase zone, class System.Web.UI.WebControls.WebParts.WebPartManager manager) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.#ctor(System.Web.UI.WebControls.WebParts.WebPartZoneBase,System.Web.UI.WebControls.WebParts.WebPartManager)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (zone As WebPartZoneBase, manager As WebPartManager)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.WebParts.WebPartChrome : System.Web.UI.WebControls.WebParts.WebPartZoneBase * System.Web.UI.WebControls.WebParts.WebPartManager -> System.Web.UI.WebControls.WebParts.WebPartChrome" Usage="new System.Web.UI.WebControls.WebParts.WebPartChrome (zone, manager)" />
<MemberSignature Language="C++ CLI" Value="public:
 WebPartChrome(System::Web::UI::WebControls::WebParts::WebPartZoneBase ^ zone, System::Web::UI::WebControls::WebParts::WebPartManager ^ manager);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="zone" Type="System.Web.UI.WebControls.WebParts.WebPartZoneBase" />
<Parameter Name="manager" Type="System.Web.UI.WebControls.WebParts.WebPartManager" />
</Parameters>
<Docs>
<param name="zone">The associated <see cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" /> control.</param>
<param name="manager">The <see cref="T:System.Web.UI.WebControls.WebParts.WebPartManager" /> control on the current page.</param>
<summary>Initializes a new instance of the control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.%23ctor%2A> initializes a new instance of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class. It is used primarily by a <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone in its <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.CreateWebPartChrome%2A> method to create an instance of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object that handles the chrome rendering and any custom rendering for <xref:System.Web.UI.WebControls.WebParts.WebPart> controls in the zone.
## Examples
The following code example demonstrates two things. First, it creates a new instance of the custom class `MyWebPartChrome` by overriding the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.CreateWebPartChrome%2A> method in a derived <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone called `MyZone`. Second, in the constructor of the `MyWebPartChrome` class, it assigns the objects in the parameters of the constructor to private fields that can be used within the class. This example thus gives you a way to access the associated zone and <xref:System.Web.UI.WebControls.WebParts.WebPartManager> object even in the constructor, before the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone%2A> and <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager%2A> properties are accessible. Finally, note that for the constructor to work, the base constructor must also be invoked as part of the method declaration.
The following code contains the two custom classes. For the full code required to run the example, including the Web page to host these controls, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="zone" /> is <see langword="null" />.</exception>
<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="CreateWebPartChromeStyle">
<MemberSignature Language="C#" Value="protected virtual System.Web.UI.WebControls.Style CreateWebPartChromeStyle (System.Web.UI.WebControls.WebParts.WebPart webPart, System.Web.UI.WebControls.WebParts.PartChromeType chromeType);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.Web.UI.WebControls.Style CreateWebPartChromeStyle(class System.Web.UI.WebControls.WebParts.WebPart webPart, valuetype System.Web.UI.WebControls.WebParts.PartChromeType chromeType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle(System.Web.UI.WebControls.WebParts.WebPart,System.Web.UI.WebControls.WebParts.PartChromeType)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Function CreateWebPartChromeStyle (webPart As WebPart, chromeType As PartChromeType) As Style" />
<MemberSignature Language="F#" Value="abstract member CreateWebPartChromeStyle : System.Web.UI.WebControls.WebParts.WebPart * System.Web.UI.WebControls.WebParts.PartChromeType -> System.Web.UI.WebControls.Style
override this.CreateWebPartChromeStyle : System.Web.UI.WebControls.WebParts.WebPart * System.Web.UI.WebControls.WebParts.PartChromeType -> System.Web.UI.WebControls.Style" Usage="webPartChrome.CreateWebPartChromeStyle (webPart, chromeType)" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual System::Web::UI::WebControls::Style ^ CreateWebPartChromeStyle(System::Web::UI::WebControls::WebParts::WebPart ^ webPart, System::Web::UI::WebControls::WebParts::PartChromeType chromeType);" />
<MemberType>Method</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.Style</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
<Parameter Name="chromeType" Type="System.Web.UI.WebControls.WebParts.PartChromeType" />
</Parameters>
<Docs>
<param name="webPart">The control that is currently being rendered.</param>
<param name="chromeType">The type of chrome for a particular control; one of the <see cref="T:System.Web.UI.WebControls.WebParts.PartChromeType" /> enumeration values.</param>
<summary>Creates the style object that supplies style attributes for each <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control rendered by the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> object.</summary>
<returns>A <see cref="T:System.Web.UI.WebControls.Style" /> that contains style attributes for the <paramref name="webPart" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method creates a <xref:System.Web.UI.WebControls.Style> object that is used by the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object to render a <xref:System.Web.UI.WebControls.WebParts.WebPart> control. The default method creates style attributes based on the <xref:System.Web.UI.WebControls.WebParts.WebZone.PartChromeType%2A> property value of the <xref:System.Web.UI.WebControls.WebParts.WebPart> control referenced in the `webPart` parameter.
A special situation occurs when a <xref:System.Web.UI.WebControls.WebParts.WebPart> control is selected. If the page is in a page display mode where controls can be selected, and the current control is actually selected, the default <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method also merges the style information of the control with the style information from the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.SelectedPartChromeStyle%2A> property.
## Examples
This code example demonstrates use of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
The following section from the code example demonstrates how to override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method. Notice that it first retrieves the style information created by the base method, and then modifies the style information by changing the font used for the <xref:System.Web.UI.WebControls.WebParts.WebPart> control being rendered.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet5":::
If you load the Web page in a browser, you can see that the font used in the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls is the one specified in the overridden <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle%2A> method.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="webPart" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="chromeType" /> is not one of the <see cref="T:System.Web.UI.WebControls.WebParts.PartChromeType" /> enumeration values.</exception>
<block subset="none" type="overrides">
<para>If you inherit from the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> class, you can optionally override the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.CreateWebPartChromeStyle(System.Web.UI.WebControls.WebParts.WebPart,System.Web.UI.WebControls.WebParts.PartChromeType)" /> method, and merge the style information from the base method with custom style attributes that you want to add. For a demonstration, see the code in the Example section.</para>
</block>
<altmember cref="P:System.Web.UI.WebControls.WebParts.WebZone.PartChromeType" />
<altmember cref="P:System.Web.UI.WebControls.WebParts.WebPartZoneBase.SelectedPartChromeStyle" />
<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="DragDropEnabled">
<MemberSignature Language="C#" Value="protected bool DragDropEnabled { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool DragDropEnabled" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.WebPartChrome.DragDropEnabled" />
<MemberSignature Language="VB.NET" Value="Protected ReadOnly Property DragDropEnabled As Boolean" />
<MemberSignature Language="F#" Value="member this.DragDropEnabled : bool" Usage="System.Web.UI.WebControls.WebParts.WebPartChrome.DragDropEnabled" />
<MemberSignature Language="C++ CLI" Value="protected:
 property bool DragDropEnabled { bool get(); };" />
<MemberType>Property</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>
<Docs>
<summary>Gets a value that indicates whether controls can be dragged into and out of the zone.</summary>
<value>A Boolean value that indicates whether controls can be dragged.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The value of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.DragDropEnabled%2A> property is determined by the value of the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase.DragDropEnabled%2A> property.
]]></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="FilterWebPartVerbs">
<MemberSignature Language="C#" Value="protected virtual System.Web.UI.WebControls.WebParts.WebPartVerbCollection FilterWebPartVerbs (System.Web.UI.WebControls.WebParts.WebPartVerbCollection verbs, System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.Web.UI.WebControls.WebParts.WebPartVerbCollection FilterWebPartVerbs(class System.Web.UI.WebControls.WebParts.WebPartVerbCollection verbs, class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.FilterWebPartVerbs(System.Web.UI.WebControls.WebParts.WebPartVerbCollection,System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Function FilterWebPartVerbs (verbs As WebPartVerbCollection, webPart As WebPart) As WebPartVerbCollection" />
<MemberSignature Language="F#" Value="abstract member FilterWebPartVerbs : System.Web.UI.WebControls.WebParts.WebPartVerbCollection * System.Web.UI.WebControls.WebParts.WebPart -> System.Web.UI.WebControls.WebParts.WebPartVerbCollection
override this.FilterWebPartVerbs : System.Web.UI.WebControls.WebParts.WebPartVerbCollection * System.Web.UI.WebControls.WebParts.WebPart -> System.Web.UI.WebControls.WebParts.WebPartVerbCollection" Usage="webPartChrome.FilterWebPartVerbs (verbs, webPart)" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual System::Web::UI::WebControls::WebParts::WebPartVerbCollection ^ FilterWebPartVerbs(System::Web::UI::WebControls::WebParts::WebPartVerbCollection ^ verbs, System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<MemberType>Method</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.WebPartVerbCollection</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="verbs" Type="System.Web.UI.WebControls.WebParts.WebPartVerbCollection" />
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="verbs">The collection of all verbs associated with the control referenced in the <paramref name="webPart" /> parameter.</param>
<param name="webPart">The control currently being rendered.</param>
<summary>Excludes specific verbs from being rendered, based on criteria provided by a developer.</summary>
<returns>A <see cref="T:System.Web.UI.WebControls.WebParts.WebPartVerbCollection" /> containing all verbs associated with the <paramref name="webPart" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.FilterWebPartVerbs%2A> method provides a way to automatically filter certain verbs from the collection of verbs associated with a <xref:System.Web.UI.WebControls.WebParts.WebPart> control, and prevent the filtered verbs from being rendered.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="verbs" /> collection is <see langword="null" />.
- or -
<paramref name="webPart" /> is <see langword="null" />.</exception>
<block subset="none" type="overrides">
<para>If you create a custom <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> class, you can optionally override the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.FilterWebPartVerbs(System.Web.UI.WebControls.WebParts.WebPartVerbCollection,System.Web.UI.WebControls.WebParts.WebPart)" /> method to filter out specific verbs from being rendered. The most common way to do this is to create a private method that checks the verbs in the <see cref="P:System.Web.UI.WebControls.WebParts.WebPart.Verbs" /> collection of a <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control and determines whether each verb should be rendered, based on criteria that you choose. Note that the base method provides a lot of default filtering criteria that would be difficult to reproduce if you completely override the method; if you only have a few special cases, you might want to call the base method first, and then pass the resulting collection through your own additional method to apply your custom filtering criteria.</para>
</block>
<altmember cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs(System.Web.UI.WebControls.WebParts.WebPart)" />
<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="GetWebPartChromeClientID">
<MemberSignature Language="C#" Value="protected string GetWebPartChromeClientID (System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig instance string GetWebPartChromeClientID(class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartChromeClientID(System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Protected Function GetWebPartChromeClientID (webPart As WebPart) As String" />
<MemberSignature Language="F#" Value="member this.GetWebPartChromeClientID : System.Web.UI.WebControls.WebParts.WebPart -> string" Usage="webPartChrome.GetWebPartChromeClientID webPart" />
<MemberSignature Language="C++ CLI" Value="protected:
 System::String ^ GetWebPartChromeClientID(System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="webPart">The control currently being rendered.</param>
<summary>Gets the client ID for the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> object as rendered in a Web page.</summary>
<returns>A string that contains the client ID for the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartChromeClientID%2A> method gets the client ID of the table that contains the `webPart` being rendered. The table is the rendered output that corresponds directly to the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object, and is used as a container to apply styles and create a modular layout for the control.
It is useful to get the client ID of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object for client-side scripting purposes, if you want to change something in the chrome without having to post the page back to the server.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="webPart" /> is <see langword="null" />.</exception>
<altmember cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartTitleClientID(System.Web.UI.WebControls.WebParts.WebPart)" />
<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="GetWebPartTitleClientID">
<MemberSignature Language="C#" Value="protected string GetWebPartTitleClientID (System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig instance string GetWebPartTitleClientID(class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartTitleClientID(System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Protected Function GetWebPartTitleClientID (webPart As WebPart) As String" />
<MemberSignature Language="F#" Value="member this.GetWebPartTitleClientID : System.Web.UI.WebControls.WebParts.WebPart -> string" Usage="webPartChrome.GetWebPartTitleClientID webPart" />
<MemberSignature Language="C++ CLI" Value="protected:
 System::String ^ GetWebPartTitleClientID(System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="webPart">The control currently being rendered.</param>
<summary>Gets the client ID for the table cell that contains the title for a <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control.</summary>
<returns>A string that contains the client ID for the title of the <paramref name="webPart" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartTitleClientID%2A> method retrieves the client ID value for the table cell that contains the title of the `webPart` being rendered.
An important scenario in which the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartTitleClientID%2A> method is used to get the client ID of the title cell of the `webPart` is for the Web Parts drag-and-drop feature. The method is also useful for other client-side scripting purposes. For example, you could change the title or the style of the cell with client-side scripting, rather than having to post the page back to the server.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="webPart" /> is <see langword="null" />.</exception>
<altmember cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartChromeClientID(System.Web.UI.WebControls.WebParts.WebPart)" />
<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="GetWebPartVerbs">
<MemberSignature Language="C#" Value="protected virtual System.Web.UI.WebControls.WebParts.WebPartVerbCollection GetWebPartVerbs (System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.Web.UI.WebControls.WebParts.WebPartVerbCollection GetWebPartVerbs(class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs(System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Function GetWebPartVerbs (webPart As WebPart) As WebPartVerbCollection" />
<MemberSignature Language="F#" Value="abstract member GetWebPartVerbs : System.Web.UI.WebControls.WebParts.WebPart -> System.Web.UI.WebControls.WebParts.WebPartVerbCollection
override this.GetWebPartVerbs : System.Web.UI.WebControls.WebParts.WebPart -> System.Web.UI.WebControls.WebParts.WebPartVerbCollection" Usage="webPartChrome.GetWebPartVerbs webPart" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual System::Web::UI::WebControls::WebParts::WebPartVerbCollection ^ GetWebPartVerbs(System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<MemberType>Method</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.WebPartVerbCollection</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="webPart">The control currently being rendered.</param>
<summary>Gets a collection of verbs that should be rendered with a <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control.</summary>
<returns>A <see cref="T:System.Web.UI.WebControls.WebParts.WebPartVerbCollection" /> containing all the verbs that should be rendered with <paramref name="webPart" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method provides developers with an opportunity to override the method and exclude certain verbs from being rendered. This is similar to the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.FilterWebPartVerbs%2A> method, which also can exclude verbs from being rendered.
However, the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method is not meant for cases where you want to check some criteria to decide whether to render a verb. Instead, this method is useful when you know in advance that you always want to exclude a certain verb. For example, if you develop a custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class, you might decide that you always want to exclude the close verb on <xref:System.Web.UI.WebControls.WebParts.WebPart> controls, so that users can never close the controls. Rather than setting the <xref:System.Web.UI.WebControls.WebParts.WebPart.AllowClose%2A> property to `false` on all the controls, you can simply override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method and exclude close verbs from being rendered on any <xref:System.Web.UI.WebControls.WebParts.WebPart> control rendered with your custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object.
## Examples
The following code example demonstrates use of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
The following section from the code example demonstrates how to override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.GetWebPartVerbs%2A> method. The overridden method uses the base method to retrieve all verbs from the `webPart` control, then iterates through the verb collection, adding all verbs except the close verb to an <xref:System.Collections.ArrayList> object. This reduced set of verbs is then assigned to a new <xref:System.Web.UI.WebControls.WebParts.WebPartVerbCollection>, which is returned to the caller.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet4":::
If you load the Web page in a browser and click the verbs menu (shown with a downward arrow in the title bar) of each <xref:System.Web.UI.WebControls.WebParts.WebPart> control, you can see that the close verb is not rendered for any control.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="webPart" /> is <see langword="null" />.</exception>
<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="PerformPreRender">
<MemberSignature Language="C#" Value="public virtual void PerformPreRender ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void PerformPreRender() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.PerformPreRender" />
<MemberSignature Language="VB.NET" Value="Public Overridable Sub PerformPreRender ()" />
<MemberSignature Language="F#" Value="abstract member PerformPreRender : unit -> unit
override this.PerformPreRender : unit -> unit" Usage="webPartChrome.PerformPreRender " />
<MemberSignature Language="C++ CLI" Value="public:
 virtual void PerformPreRender();" />
<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 />
<Docs>
<summary>Performs tasks that must be done prior to rendering <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> 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="RenderPartContents">
<MemberSignature Language="C#" Value="protected virtual void RenderPartContents (System.Web.UI.HtmlTextWriter writer, System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void RenderPartContents(class System.Web.UI.HtmlTextWriter writer, class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub RenderPartContents (writer As HtmlTextWriter, webPart As WebPart)" />
<MemberSignature Language="F#" Value="abstract member RenderPartContents : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.WebPart -> unit
override this.RenderPartContents : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.WebPart -> unit" Usage="webPartChrome.RenderPartContents (writer, webPart)" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual void RenderPartContents(System::Web::UI::HtmlTextWriter ^ writer, System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<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="writer" Type="System.Web.UI.HtmlTextWriter" />
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> that receives the <paramref name="webPart" /> content.</param>
<param name="webPart">The control currently being rendered.</param>
<summary>Renders the main content area of a <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control, excluding the header and footer.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents%2A> method enables you to override the rendering of the body area of `webPart`, while leaving rendering of the header and footer to the default rendering.
## Examples
The following code example demonstrates use of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents%2A> method. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
The following section from the code example demonstrates how to override the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents%2A> method. The overridden method does two things to customize the rendering for the body of the <xref:System.Web.UI.WebControls.WebParts.WebPart> control. First, it checks to determine whether the control is currently selected, and if so, writes out a string and does not render the contents. Second, if the control is not selected, and if the control's zone is of type `MyZone`, the method renders the control. This latter check could be used if you wanted to ensure that a custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class can be used only to render <xref:System.Web.UI.WebControls.WebParts.WebPart> controls in a specific type of <xref:System.Web.UI.WebControls.WebParts.WebPartZone> zone that is designed to contain the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet6":::
If you load the Web page in a browser, you can see that the content of each control is rendered normally. If you switch the page into design mode (by selecting **Design** in the **Display Mode** drop-down list control) and drag one of the controls into the empty zone labeled **WebPartZone2**, the contents of the control are rendered differently, because the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object is not being used for the rendering in a standard zone. This is the same effect that you would achieve if you tried to use the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class with any other zone besides the `MyZone` class, due to the preceding source code.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You can optionally override the <see cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" /> method. If so, you can simply perform whatever rendering customizations you want for <paramref name="webPart" />, and then call its <see cref="M:System.Web.UI.Control.RenderControl(System.Web.UI.HtmlTextWriter)" /> method. If you also want to rely on the default rendering in the event of connection errors, call the base method first, and then customize the <paramref name="writer" /> that is returned from the base method.</para>
</block>
<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="RenderWebPart">
<MemberSignature Language="C#" Value="public virtual void RenderWebPart (System.Web.UI.HtmlTextWriter writer, System.Web.UI.WebControls.WebParts.WebPart webPart);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void RenderWebPart(class System.Web.UI.HtmlTextWriter writer, class System.Web.UI.WebControls.WebParts.WebPart webPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderWebPart(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" />
<MemberSignature Language="VB.NET" Value="Public Overridable Sub RenderWebPart (writer As HtmlTextWriter, webPart As WebPart)" />
<MemberSignature Language="F#" Value="abstract member RenderWebPart : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.WebPart -> unit
override this.RenderWebPart : System.Web.UI.HtmlTextWriter * System.Web.UI.WebControls.WebParts.WebPart -> unit" Usage="webPartChrome.RenderWebPart (writer, webPart)" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual void RenderWebPart(System::Web::UI::HtmlTextWriter ^ writer, System::Web::UI::WebControls::WebParts::WebPart ^ webPart);" />
<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="writer" Type="System.Web.UI.HtmlTextWriter" />
<Parameter Name="webPart" Type="System.Web.UI.WebControls.WebParts.WebPart" />
</Parameters>
<Docs>
<param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> that receives the <paramref name="webPart" /> content.</param>
<param name="webPart">The control currently being rendered.</param>
<summary>Renders a complete <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> control with all its sections.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderWebPart%2A> method renders the complete <xref:System.Web.UI.WebControls.WebParts.WebPart> control, with header, contents, and footer. Overriding this method gives a developer complete programmatic control over rendering all aspects of `webPart`, and for that reason, overriding this method is quite complex. As with some other methods in the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class that developers can override, if you override this method, a common and useful approach is to call the base method first, take the <xref:System.Web.UI.WebControls.WebParts.WebPart> control that is returned, and customize some of its properties, rather than handling the complete rendering yourself.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The control that <paramref name="webPart" /> refers to is <see langword="null" />.</exception>
<altmember cref="M:System.Web.UI.WebControls.WebParts.WebPartChrome.RenderPartContents(System.Web.UI.HtmlTextWriter,System.Web.UI.WebControls.WebParts.WebPart)" />
<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="WebPartManager">
<MemberSignature Language="C#" Value="protected System.Web.UI.WebControls.WebParts.WebPartManager WebPartManager { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.WebParts.WebPartManager WebPartManager" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager" />
<MemberSignature Language="VB.NET" Value="Protected ReadOnly Property WebPartManager As WebPartManager" />
<MemberSignature Language="F#" Value="member this.WebPartManager : System.Web.UI.WebControls.WebParts.WebPartManager" Usage="System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager" />
<MemberSignature Language="C++ CLI" Value="protected:
 property System::Web::UI::WebControls::WebParts::WebPartManager ^ WebPartManager { System::Web::UI::WebControls::WebParts::WebPartManager ^ get(); };" />
<MemberType>Property</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#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.WebPartManager</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a reference to the current <see cref="T:System.Web.UI.WebControls.WebParts.WebPartManager" /> instance.</summary>
<value>A reference to the current <see cref="T:System.Web.UI.WebControls.WebParts.WebPartManager" /> on the Web page.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager%2A> property provides a reference to the current <xref:System.Web.UI.WebControls.WebParts.WebPartManager> instance on the page.
## Examples
This code example demonstrates use of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager%2A> property. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
The following code example uses the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartManager%2A> property to determine whether the current <xref:System.Web.UI.WebControls.WebParts.WebPart> control being rendered is the selected control, which in this example means that the page is in edit view, and the control is currently being edited. If these conditions are true, the body of the control is not rendered, and a string is written in its place.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet6":::
If you load the Web page in a browser, you can switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the edit verb in the verbs menu of either of the controls; when the page is rendered, the body of the control selected for editing is not rendered. However, if you drag the control into the empty zone labeled **WebPartZone2**, the body of the control is rendered. This is because the second zone is a standard <xref:System.Web.UI.WebControls.WebParts.WebPartZone> zone, and it does not use the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class in this example to render the <xref:System.Web.UI.WebControls.WebParts.WebPart> controls.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.WebParts.WebPartManager" />
<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="Zone">
<MemberSignature Language="C#" Value="protected System.Web.UI.WebControls.WebParts.WebPartZoneBase Zone { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.WebParts.WebPartZoneBase Zone" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone" />
<MemberSignature Language="VB.NET" Value="Protected ReadOnly Property Zone As WebPartZoneBase" />
<MemberSignature Language="F#" Value="member this.Zone : System.Web.UI.WebControls.WebParts.WebPartZoneBase" Usage="System.Web.UI.WebControls.WebParts.WebPartChrome.Zone" />
<MemberSignature Language="C++ CLI" Value="protected:
 property System::Web::UI::WebControls::WebParts::WebPartZoneBase ^ Zone { System::Web::UI::WebControls::WebParts::WebPartZoneBase ^ get(); };" />
<MemberType>Property</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#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.WebPartZoneBase</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a reference to the associated <see cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" /> zone.</summary>
<value>A reference to a <see cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" /> that is associated with the <see cref="T:System.Web.UI.WebControls.WebParts.WebPartChrome" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone%2A> property provides a reference to the <xref:System.Web.UI.WebControls.WebParts.WebPartZoneBase> zone that contains the controls for which the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object provides rendering.
## Examples
This code example demonstrates use of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone%2A> property. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class overview topic.
The following code example uses the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome.Zone%2A> property to determine whether the zone currently associated with the <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object is a zone of type `MyZone`. If so, the control's contents are rendered. This code would prevent the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object from working with any other zone besides the one designed to create an instance of it.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/CS/MyChrome.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_WebPartChrome_Overview/VB/MyChrome.vb" id="Snippet6":::
If you load the Web page in a browser, the content of each control is rendered normally. You can switch the page into design mode by selecting **Design** in the **Display Mode** drop-down list control. If you drag one of the controls into the empty zone labeled **WebPartZone2**, its contents are rendered differently, because the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> object is not being used for the rendering. This is the same effect that you would achieve if you tried to use the custom <xref:System.Web.UI.WebControls.WebParts.WebPartChrome> class with any other zone besides the `MyZone` class, because of the preceding source code.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.WebParts.WebPartZoneBase" />
<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>