PanelDesigner Class
Extends design-time behavior for the Panel Web server control.
For a list of all members of this type, see PanelDesigner Members.
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.ReadWriteControlDesigner
System.Web.UI.Design.WebControls.PanelDesigner
[Visual Basic] Public Class PanelDesigner Inherits ReadWriteControlDesigner [C#] public class PanelDesigner : ReadWriteControlDesigner [C++] public __gc class PanelDesigner : public ReadWriteControlDesigner [JScript] public class PanelDesigner extends ReadWriteControlDesigner
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Example
[Visual Basic] The following code example shows a custom class, named CustomPanelDesigner, that derives from the PanelDesigner class. It overrides the MapPropertyToStyle and OnBehaviorAttached methods. This designer is used with a custom control, named CustomPanel, that derives from the Panel class. When this designer is attached to the CustomPanel class, it converts the Panel class's Wrap property to the NoWrap HTML attribute.
[Visual Basic] Note The PanelDesigner class derives directly from the ReadWriteControlDesigner class. You can override ReadWriteControlDesigner directly to accomplish the same conversion of the Panel.Wrap property in the designer. However, if you do this you will lose the base MapPropertyToStyle method processing offered by the PanelDesigner class.
[Visual Basic]
' Create a class that derives from the PanelDesigner
' class. Because PanelDesigner derives directly
' from ReadWriteControlDesigner, you could derive
' from the latter to accomplish the same design-
' time functionality found in this example.
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing.Design
Imports Microsoft.Win32
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Namespace AspNet.Samples.Design
' The CustomPanelDesigner class is designed to be
' attached to a class that inherits the System.Web.UI.
' Panel class.
Public Class CustomPanelDesigner
Inherits PanelDesigner
' Override the MapPropertyToStyle method to set the
' Panel.Wrap property to the NoWrap HTML attribute.
Overrides Protected Sub MapPropertyToStyle(propName As String, varPropValue As Object)
' Display messages when debugging.
Debug.Assert(Not (propName = Nothing Or propName.Length <> 0), "Invalid property name passed in.")
Debug.Assert(Not (varPropValue = Nothing), "Invalid property value passed in.")
' If the parameters passed to the method are null,
' return nothing.
If ((propName Is Nothing) And (varPropValue Is Nothing)) Then
Return
End If
' If the second parameter is not a null
' value, check whether the property name is Wrap.
If Not (varPropValue Is Nothing) Then
Try
' If property name is wrap, convert
' it to the HTML NoWrap attribute.
If (propName.Equals("Wrap")) Then
Dim strValue As String = String.Empty
If (CType(varPropValue, Boolean)) Then
Behavior.SetStyleAttribute("NoWrap", True, strValue, True)
End If
Else
MyBase.MapPropertyToStyle(propName, varPropValue)
End If
Catch ex As Exception
Debug.Fail(ex.ToString())
End Try
End If
End Sub 'MapPropertyToStyle
' Override the OnBehaviorAttached method to call
' the MapPropertyToStyle method when the designer
' control's wrap property is set to true.
Overrides Protected Sub OnBehaviorAttached()
MyBase.OnBehaviorAttached()
Dim component As IComponent
Dim panel As CustomPanel = CType(component, CustomPanel)
Dim wrap As Boolean = panel.Wrap
If wrap Then
MapPropertyToStyle("Wrap", wrap)
End If
End Sub 'OnBehaviorAttached
End Class
End Namespace
[Visual Basic] The following code example is a custom Panel class, named CustomPanel, that is associated with the CustomPanelDesigner class shown above.
[Visual Basic]
' Create the class that uses the
' CustomPanelDesigner class to be
' displayed at design time.
<Designer(GetType( _
AspNet.Samples.Design.CustomPanelDesigner))> _
Public Class CustomPanel
Inherits System.Web.UI.WebControls.Panel
Overrides Public Property Wrap As Boolean
Get
Return MyBase.Wrap
End Get
Set
MyBase.Wrap = value
End Set
End Property
End Class
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI.Design.WebControls
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Design (in System.Design.dll)
See Also
PanelDesigner Members | System.Web.UI.Design.WebControls Namespace | Panel