This documentation is archived and is not being maintained.

PanelContainerDesigner Class

Provides design-time support in a visual designer for the Panel control.

Namespace:  System.Web.UI.Design.WebControls
Assembly:  System.Design (in System.Design.dll)

public class PanelContainerDesigner : ContainerControlDesigner

The Panel control is used as a container for other controls, especially when controls are generated programmatically.

In a visual designer, when you switch from Source to Design view, the markup source code that describes the associated Panel control is parsed, and a design-time version of the control is created on the design surface. When you switch back to Source view, the design-time control is persisted to markup source code and edited into the markup for the Web page. The PanelContainerDesigner class provides design-time support for Panel controls in a visual designer.

The FrameCaption property gets the caption that appears on the associated Panel control. The FrameStyle property gets the styles of the associated control.

The UsePreviewControl property always returns true, indicating that the designer creates a temporary copy of the associated Panel to generate the design-time markup.

The Initialize method prepares the designer to view, edit, and design the associated Panel control. The AddDesignTimeCssAttributes method sets collection elements to the string representations of various style attributes of the associated control.

The following code example shows how to extend the PanelContainerDesigner class to change the appearance and behavior of controls that are derived from the Panel control at design time.

The example derives the MyPanelContainer class from the Panel control. The example also derives the MyPanelContainerDesigner class from the PanelContainerDesigner class and applies a DesignerAttribute attribute for the MyPanelContainerDesigner on the MyPanelContainer class.

The MyPanelContainerDesigner overrides the following PanelContainerDesigner members:

  • The FrameStyle property to define a design-time border style for the MyPanelContainer control.

  • The FrameCaption property to provide a default caption for the MyPanelContainer control, if none was defined.

  • The Initialize method to throw an ArgumentException exception, if the associated control is not a MyPanelContainer object.

using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.ComponentModel;
using System.Security.Permissions;

namespace Examples.CS.WebControls.Design
    // The MyPanelContainer is a copy of the Panel.
        Level = AspNetHostingPermissionLevel.Minimal)]
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyPanelContainer : Panel
    } // MyPanelContainer 

    // Override members of the PanelContainerDesigner. 
    public class MyPanelContainerDesigner : PanelContainerDesigner
        // Provide a design-time caption for the panel. 
        public override string FrameCaption 
                // If the FrameCaption is empty, use the panel control ID.
                string localCaption = base.FrameCaption;
                if (localCaption == null || localCaption == "")
                    localCaption = ((Panel)Component).ID.ToString();

                return localCaption;
        } // FrameCaption 

        // Provide a design-time border style for the panel. 
        public override Style FrameStyle
                Style styleOfFrame = base.FrameStyle;

                // If no border style is defined, define one. 
                if (styleOfFrame.BorderStyle == BorderStyle.NotSet ||
                    styleOfFrame.BorderStyle == BorderStyle.None)
                    styleOfFrame.BorderStyle = BorderStyle.Outset;

                return styleOfFrame;
        } // FrameStyle 

        // Initialize the designer. 
        public override void Initialize(IComponent component)
            // Ensure that only a MyPanelContainer can be created  
            // in this designer. 
            if (!(component is MyPanelContainer))
                throw new ArgumentException();


        } // Initialize
    } // MyPanelContainerDesigner
} // Examples.CS.WebControls.Design

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0