File: WebZone.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (686 lines) | stat: -rw-r--r-- 25,485 bytes parent folder | download | duplicates (7)
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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
//------------------------------------------------------------------------------
// <copyright file="WebZone.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Web.UI.WebControls.WebParts {

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Design;
    using System.Globalization;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Util;

    /// <devdoc>
    /// Base class for all zone classes in the WebPart framework.  Contains properties used to control the UI
    /// which is common to all zone classes.
    /// </devdoc>
    [
    Designer("System.Web.UI.Design.WebControls.WebParts.WebZoneDesigner, " + AssemblyRef.SystemDesign),
    Bindable(false),
    ]
    public abstract class WebZone : CompositeControl {

        private WebPartManager _webPartManager;

        private const int baseIndex = 0;
        private const int emptyZoneTextStyleIndex = 1;
        private const int footerStyleIndex = 2;
        private const int partStyleIndex = 3;
        private const int partChromeStyleIndex = 4;
        private const int partTitleStyleIndex = 5;
        private const int headerStyleIndex = 6;
        private const int verbStyleIndex = 7;
        private const int errorStyleIndex = 8;
        private const int viewStateArrayLength = 9;

        private Style _emptyZoneTextStyle;
        private TitleStyle _footerStyle;
        private TableStyle _partStyle;
        private Style _partChromeStyle;
        private TitleStyle _partTitleStyle;
        private TitleStyle _headerStyle;
        private Style _verbStyle;
        private Style _errorStyle;

        // Prevent class from being subclassed outside of our assembly
        internal WebZone() {
        }

        /// <devdoc>
        /// The URL of the background image for the control.
        /// </devdoc>
        [
        DefaultValue(""),
        Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
        UrlProperty(),
        WebCategory("Appearance"),
        WebSysDescription(SR.WebControl_BackImageUrl)
        ]
        public virtual string BackImageUrl {
            get {
                string s = (string)ViewState["BackImageUrl"];
                return((s == null) ? String.Empty : s);
            }
            set {
                ViewState["BackImageUrl"] = value;
            }
        }

        [
        // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes
        Localizable(true),
        WebSysDefaultValue(""),
        WebCategory("Behavior"),
        WebSysDescription(SR.Zone_EmptyZoneText),
        ]
        public virtual string EmptyZoneText {
            get {
                string s = (string)ViewState["EmptyZoneText"];
                return((s == null) ? String.Empty : s);
            }
            set {
                ViewState["EmptyZoneText"] = value;
            }
        }

        [
        DefaultValue(null),
        NotifyParentProperty(true),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("Styles"),
        WebSysDescription(SR.Zone_EmptyZoneTextStyle),
        ]
        public Style EmptyZoneTextStyle {
            get {
                if (_emptyZoneTextStyle == null) {
                    _emptyZoneTextStyle = new Style();
                    if (IsTrackingViewState) {
                        ((IStateManager)_emptyZoneTextStyle).TrackViewState();
                    }
                }

                return _emptyZoneTextStyle;
            }
        }

        [
        DefaultValue(null),
        NotifyParentProperty(true),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("Styles"),
        WebSysDescription(SR.Zone_ErrorStyle),
        ]
        public Style ErrorStyle {
            get {
                if (_errorStyle == null) {
                    _errorStyle = new ErrorStyle();
                    if (IsTrackingViewState) {
                        ((IStateManager)_errorStyle).TrackViewState();
                    }
                }

                return _errorStyle;
            }
        }

        /// <devdoc>
        /// Style for the footer of the zone.
        /// </devdoc>
        [
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("Styles"),
        WebSysDescription(SR.Zone_FooterStyle)
        ]
        public TitleStyle FooterStyle {
            get {
                if (_footerStyle == null) {
                    _footerStyle = new TitleStyle();
                    if (IsTrackingViewState) {
                        ((IStateManager)_footerStyle).TrackViewState();
                    }
                }

                return _footerStyle;
            }
        }

        protected virtual bool HasFooter {
            get {
                return true;
            }
        }

        protected virtual bool HasHeader {
            get {
                return true;
            }
        }

        /// <devdoc>
        /// The header text of the zone.
        /// </devdoc>
        [
        // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes
        Localizable(true),
        WebSysDefaultValue(""),
        WebCategory("Appearance"),
        WebSysDescription(SR.Zone_HeaderText)
        ]
        public virtual string HeaderText {
            get {
                string s = (string)ViewState["HeaderText"];
                return((s == null) ? String.Empty : s);
            }
            set {
                ViewState["HeaderText"] = value;
            }
        }

        /// <devdoc>
        /// Style for the title bar of the zone.
        /// </devdoc>
        [
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("Styles"),
        WebSysDescription(SR.Zone_HeaderStyle)
        ]
        public TitleStyle HeaderStyle {
            get {
                if (_headerStyle == null) {
                    _headerStyle = new TitleStyle();
                    if (IsTrackingViewState) {
                        ((IStateManager)_headerStyle).TrackViewState();
                    }
                }

                return _headerStyle;
            }
        }

        /// <devdoc>
        /// Padding for the contained parts.
        /// </devdoc>
        [
        DefaultValue(typeof(Unit), "5px"),
        WebCategory("WebPart"),
        WebSysDescription(SR.Zone_PartChromePadding)
        ]
        public Unit PartChromePadding {
            get {
                object obj = ViewState["PartChromePadding"];
                return (obj == null) ? Unit.Pixel(5) : (Unit)obj;
            }
            set {
                if (value.Value < 0) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["PartChromePadding"] = value;
            }
        }

        /// <devdoc>
        /// Style for the contained parts.
        /// </devdoc>
        [
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("WebPart"),
        WebSysDescription(SR.Zone_PartChromeStyle)
        ]
        public Style PartChromeStyle {
            get {
                if (_partChromeStyle == null) {
                    _partChromeStyle = new Style();
                    if (IsTrackingViewState) {
                        ((IStateManager)_partChromeStyle).TrackViewState();
                    }
                }

                return _partChromeStyle;
            }
        }

        /// <devdoc>
        /// The type of frame/border for the contained parts.
        /// </devdoc>
        [
        DefaultValue(PartChromeType.Default),
        WebCategory("WebPart"),
        WebSysDescription(SR.Zone_PartChromeType)
        ]
        public virtual PartChromeType PartChromeType {
            get {
                object o = ViewState["PartChromeType"];
                return (o != null) ? (PartChromeType)(int)o : PartChromeType.Default;
            }
            set {
                if ((value < PartChromeType.Default) || (value > PartChromeType.BorderOnly)) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["PartChromeType"] = (int)value;
            }
        }

        /// <devdoc>
        /// Style for the contents of the contained parts.
        /// </devdoc>
        [
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("WebPart"),
        WebSysDescription(SR.Zone_PartStyle)
        ]
        public TableStyle PartStyle {
            get {
                if (_partStyle == null) {
                    _partStyle = new TableStyle();
                    if (IsTrackingViewState) {
                        ((IStateManager)_partStyle).TrackViewState();
                    }
                }

                return _partStyle;
            }
        }

        /// <devdoc>
        /// Style for the title bars of the contained parts.
        /// </devdoc>
        [
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("WebPart"),
        WebSysDescription(SR.Zone_PartTitleStyle)
        ]
        public TitleStyle PartTitleStyle {
            get {
                if (_partTitleStyle == null) {
                    _partTitleStyle = new TitleStyle();
                    if (IsTrackingViewState) {
                        ((IStateManager)_partTitleStyle).TrackViewState();
                    }
                }

                return _partTitleStyle;
            }
        }

        protected override HtmlTextWriterTag TagKey {
            get {
                return HtmlTextWriterTag.Table;
            }
        }

        // Padding = -1 means we will not render anything for the cellpadding attribute
        [
        DefaultValue(2),
        WebCategory("Layout"),
        WebSysDescription(SR.Zone_Padding),
        ]
        public virtual int Padding {
            get {
                object obj = ViewState["Padding"];
                return (obj == null) ? 2 : (int) obj;
            }
            set {
                if (value < -1) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["Padding"] = value;
            }
        }

        // Called by WebPartZoneBase, EditorZoneBase, CatalogZoneBase, and ConnectionsZone.
        internal void RenderBodyTableBeginTag(HtmlTextWriter writer) {
            // 


            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            int padding = Padding;
            if (padding >= 0) {
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, padding.ToString(CultureInfo.InvariantCulture));
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");

            // Copied from Panel.cs
            // 
            string backImageUrl = BackImageUrl;
            // Whidbey 12856
            if (backImageUrl.Trim().Length > 0)
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage,"url(" + ResolveClientUrl(backImageUrl) + ")");

            // Needed if Zone HeaderText is wider than contained Parts
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");

            // Needed if the height of the Zone is taller than the height of its contents
            writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");

            writer.RenderBeginTag(HtmlTextWriterTag.Table);
        }

        // Called by WebPartZoneBase, EditorZoneBase, CatalogZoneBase, and ConnectionsZone.
        internal static void RenderBodyTableEndTag(HtmlTextWriter writer) {
            writer.RenderEndTag();  // Table
        }

        // Called by WebPartZoneBase, EditorZoneBase, and CatalogZoneBase.
        internal void RenderDesignerRegionBeginTag(HtmlTextWriter writer, Orientation orientation) {
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            if (orientation == Orientation.Horizontal) {
                writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            }
            writer.AddAttribute(HtmlTextWriterAttribute.DesignerRegion, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, Padding.ToString(CultureInfo.InvariantCulture));
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            if (orientation == Orientation.Vertical) {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            }
            else {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
        }

        // Called by WebPartZoneBase, EditorZoneBase, and CatalogZoneBase.
        internal static void RenderDesignerRegionEndTag(HtmlTextWriter writer) {
            writer.RenderEndTag(); // Table
            writer.RenderEndTag(); // Td
            writer.RenderEndTag(); // Tr
        }

        protected internal bool RenderClientScript {
            get {
                bool renderClientScript = false;
                if (DesignMode) {
                    renderClientScript = true;
                }
                else if (WebPartManager != null) {
                    renderClientScript = WebPartManager.RenderClientScript;
                }
                return renderClientScript;
            }
        }

        /// <devdoc>
        /// The type of the button rendered for each verb.
        /// </devdoc>
        [
        DefaultValue(ButtonType.Button),
        WebCategory("Appearance"),
        WebSysDescription(SR.Zone_VerbButtonType),
        ]
        public virtual ButtonType VerbButtonType {
            get {
                object obj = ViewState["VerbButtonType"];
                return (obj == null) ? ButtonType.Button : (ButtonType)obj;
            }
            set {
                if (value < ButtonType.Button || value > ButtonType.Link) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["VerbButtonType"] = value;
            }
        }

        [
        DefaultValue(null),
        NotifyParentProperty(true),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        PersistenceMode(PersistenceMode.InnerProperty),
        WebCategory("Styles"),
        WebSysDescription(SR.Zone_VerbStyle),
        ]
        public Style VerbStyle {
            get {
                if (_verbStyle == null) {
                    _verbStyle = new Style();
                    if (IsTrackingViewState) {
                        ((IStateManager)_verbStyle).TrackViewState();
                    }
                }

                return _verbStyle;
            }
        }

        /// <devdoc>
        /// The effective chrome type of a part, taking into consideration the PartChromeType
        /// of the zone and the DisplayMode of the page.
        /// </devdoc>
        public virtual PartChromeType GetEffectiveChromeType(Part part) {
            if (part == null) {
                throw new ArgumentNullException("part");
            }

            PartChromeType chromeType = part.ChromeType;
            if (chromeType == PartChromeType.Default) {
                PartChromeType partChromeType = PartChromeType;
                if (partChromeType == PartChromeType.Default) {
                    chromeType = PartChromeType.TitleAndBorder;
                }
                else {
                    chromeType = partChromeType;
                }
            }

            Debug.Assert(chromeType != PartChromeType.Default);
            return chromeType;
        }

        protected override void LoadViewState(object savedState) {
            if (savedState == null) {
                base.LoadViewState(null);
            }
            else {
                object[] myState = (object[]) savedState;
                if (myState.Length != viewStateArrayLength) {
                    throw new ArgumentException(SR.GetString(SR.ViewState_InvalidViewState));
                }

                base.LoadViewState(myState[baseIndex]);
                if (myState[emptyZoneTextStyleIndex] != null) {
                    ((IStateManager) EmptyZoneTextStyle).LoadViewState(myState[emptyZoneTextStyleIndex]);
                }
                if (myState[footerStyleIndex] != null) {
                    ((IStateManager) FooterStyle).LoadViewState(myState[footerStyleIndex]);
                }
                if (myState[partStyleIndex] != null) {
                    ((IStateManager) PartStyle).LoadViewState(myState[partStyleIndex]);
                }
                if (myState[partChromeStyleIndex] != null) {
                    ((IStateManager) PartChromeStyle).LoadViewState(myState[partChromeStyleIndex]);
                }
                if (myState[partTitleStyleIndex] != null) {
                    ((IStateManager) PartTitleStyle).LoadViewState(myState[partTitleStyleIndex]);
                }
                if (myState[headerStyleIndex] != null) {
                    ((IStateManager) HeaderStyle).LoadViewState(myState[headerStyleIndex]);
                }
                if (myState[verbStyleIndex] != null) {
                    ((IStateManager) VerbStyle).LoadViewState(myState[verbStyleIndex]);
                }
                if (myState[errorStyleIndex] != null) {
                    ((IStateManager) ErrorStyle).LoadViewState(myState[errorStyleIndex]);
                }
            }
        }

        protected internal override void OnInit(EventArgs e) {
            base.OnInit(e);

            Page page = Page;
            Debug.Assert(page != null);
            if (page != null) {
                if (page.ControlState >= ControlState.Initialized && !DesignMode) {
                    throw new InvalidOperationException(SR.GetString(SR.Zone_AddedTooLate));
                }

                if (!DesignMode) {
                    _webPartManager = WebPartManager.GetCurrentWebPartManager(page);
                    if (_webPartManager == null) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartManagerRequired));
                    }

                    _webPartManager.RegisterZone(this);
                }
            }
        }

        protected internal override void OnPreRender(EventArgs e) {
            base.OnPreRender(e);

            Control parent = Parent;
            Debug.Assert(parent != null);
            if (parent != null && (parent is WebZone || parent is Part)) {
                throw new InvalidOperationException(SR.GetString(SR.Zone_InvalidParent));
            }
        }

        public override void RenderBeginTag(HtmlTextWriter writer) {
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");

            // On Mac IE, if height is not set, render height:1px, so the table sizes to contents.
            // Otherwise, Mac IE may give the table an arbitrary height (equal to the width of its contents).
            if (!DesignMode &&
                Page != null &&
                Page.Request.Browser.Type == "IE5" &&
                Page.Request.Browser.Platform == "MacPPC" &&
                (!ControlStyleCreated || ControlStyle.Height == Unit.Empty)) {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "1px");
            }

            // Render <table>
            base.RenderBeginTag(writer);
        }

        protected internal override void RenderContents(HtmlTextWriter writer) {
            if (HasHeader) {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                TitleStyle headerStyle = HeaderStyle;
                if (!headerStyle.IsEmpty) {
                    headerStyle.AddAttributesToRender(writer, this);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderHeader(writer);
                writer.RenderEndTag();  // Td
                writer.RenderEndTag();  // Tr
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // We want the body to fill the height of the zone, and squish the header and footer
            // to the size of their contents
            // Mac IE needs height=100% set on <td> instead of <tr>
            writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");

            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            RenderBody(writer);
            writer.RenderEndTag();  // Td
            writer.RenderEndTag();  // Tr

            if (HasFooter) {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                TitleStyle footerStyle = FooterStyle;
                if (!footerStyle.IsEmpty) {
                    footerStyle.AddAttributesToRender(writer, this);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderFooter(writer);
                writer.RenderEndTag();  // Td
                writer.RenderEndTag();  // Tr
            }
        }

        protected virtual void RenderHeader(HtmlTextWriter writer) {
        }

        protected virtual void RenderBody(HtmlTextWriter writer) {
        }

        protected virtual void RenderFooter(HtmlTextWriter writer) {
        }

        protected override object SaveViewState() {
            object[] myState = new object[viewStateArrayLength];

            myState[baseIndex] = base.SaveViewState();
            myState[emptyZoneTextStyleIndex] = (_emptyZoneTextStyle != null) ? ((IStateManager)_emptyZoneTextStyle).SaveViewState() : null;
            myState[footerStyleIndex] = (_footerStyle != null) ? ((IStateManager)_footerStyle).SaveViewState() : null;
            myState[partStyleIndex] = (_partStyle != null) ? ((IStateManager)_partStyle).SaveViewState() : null;
            myState[partChromeStyleIndex] = (_partChromeStyle != null) ? ((IStateManager)_partChromeStyle).SaveViewState() : null;
            myState[partTitleStyleIndex] = (_partTitleStyle != null) ? ((IStateManager)_partTitleStyle).SaveViewState() : null;
            myState[headerStyleIndex] = (_headerStyle != null) ? ((IStateManager)_headerStyle).SaveViewState() : null;
            myState[verbStyleIndex] = (_verbStyle != null) ? ((IStateManager)_verbStyle).SaveViewState() : null;
            myState[errorStyleIndex] = (_errorStyle != null) ? ((IStateManager)_errorStyle).SaveViewState() : null;

            for (int i=0; i < viewStateArrayLength; i++) {
                if (myState[i] != null) {
                    return myState;
                }
            }

            // More performant to return null than an array of null values
            return null;
        }

        protected override void TrackViewState() {
            base.TrackViewState();

            if (_emptyZoneTextStyle != null) {
                ((IStateManager) _emptyZoneTextStyle).TrackViewState();
            }
            if (_footerStyle != null) {
                ((IStateManager) _footerStyle).TrackViewState();
            }
            if (_partStyle != null) {
                ((IStateManager) _partStyle).TrackViewState();
            }
            if (_partChromeStyle != null) {
                ((IStateManager) _partChromeStyle).TrackViewState();
            }
            if (_partTitleStyle != null) {
                ((IStateManager) _partTitleStyle).TrackViewState();
            }
            if (_headerStyle != null) {
                ((IStateManager) _headerStyle).TrackViewState();
            }
            if (_verbStyle != null) {
                ((IStateManager) _verbStyle).TrackViewState();
            }
            if (_errorStyle != null) {
                ((IStateManager) _errorStyle).TrackViewState();
            }
        }

        protected WebPartManager WebPartManager {
            get {
                return _webPartManager;
            }
        }
    }
}