Export (0) Print
Expand All

ReadWriteControlDesigner Class

Extends design-time behavior for read/write server controls.

For a list of all members of this type, see ReadWriteControlDesigner 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 ReadWriteControlDesigner
   Inherits ControlDesigner
[C#]
public class ReadWriteControlDesigner : ControlDesigner
[C++]
public __gc class ReadWriteControlDesigner : public ControlDesigner
[JScript]
public class ReadWriteControlDesigner extends ControlDesigner

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.

Remarks

This control designer provides the ability to drop controls onto the control for this designer.

Notes to Implementers:  Implementers of designers who would like their control to support adding child controls to it should use the ReadWriteControlDesigner class. If you do not want your control to support child controls, use a designer derived from the ControlDesigner class.

Example

[Visual Basic] The following code example shows a CustomPanelDesigner class that derives from the PanelDesigner class. It checks the parameter values passed to the MapPropertyToStyle method and if they correspond to the Panel. System.Web.UI.Panel.Wrap property, the property and its value are mapped to the HMTL NoWrap attribute.

[Visual Basic] The PanelDesigner class derives directly from the ReadWriteControlDesigner class so you can override ReadWriteControlDesigner directly to accomplish the same property mapping. However, you would lose the base method processing offered by the PanelDesigner.MapPropertyToStyle method.

[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 shows a custom Panel class, named CustomPanel, that is associated with the CustomPanelDesigner class shown in the preceding example.

[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 Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI.Design

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Design (in System.Design.dll)

See Also

ReadWriteControlDesigner Members | System.Web.UI.Design Namespace

Show:
© 2014 Microsoft