WebPartZoneAutoFormat.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebParts / WebPartZoneAutoFormat.cs / 1 / WebPartZoneAutoFormat.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.Design.WebControls.WebParts { 
 
    using System.Data;
    using System.Design; 
    using System.Web.UI.WebControls.WebParts;

    internal sealed class WebPartZoneAutoFormat : BaseAutoFormat {
 
        public WebPartZoneAutoFormat(DataRow schemeData) : base(schemeData) {
            // Use default Height 
            Style.Width = 250; 
        }
 
        public override Control GetPreviewControl(Control runtimeControl) {
            WebPartZone previewZone = (WebPartZone)base.GetPreviewControl(runtimeControl);

            // If the zone contains no WebParts, set the ZoneTemplate to a dummy Template, so 
            // that there is at least one WebPart in the AutoFormat preview
            if (previewZone != null && previewZone.WebParts.Count == 0) { 
                previewZone.ZoneTemplate = new AutoFormatTemplate(); 
            }
 
            return previewZone;
        }

        private sealed class AutoFormatTemplate : ITemplate { 
            public void InstantiateIn(Control container) {
                container.Controls.Add(new SampleWebPart()); 
            } 

            private sealed class SampleWebPart : WebPart { 
                public SampleWebPart() {
                    Title = SR.GetString(SR.WebPartZoneAutoFormat_SampleWebPartTitle);
                    ID = "SampleWebPart";
                } 

                protected override void RenderContents(HtmlTextWriter writer) { 
                    writer.Write(SR.GetString(SR.WebPartZoneAutoFormat_SampleWebPartContents)); 
                }
            } 
        }
    }
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK