Microsoft.SharePoint.WebCon ...


SPControlDesigner Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<PermissionSetAttribute(SecurityAction.LinkDemand, Name:="FullTrust")> _
Public NotInheritable Class SPControlDesigner
    Inherits ControlDesigner
Visual Basic (Usage)
Dim instance As SPControlDesigner
C#
[PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")] 
public sealed class SPControlDesigner : ControlDesigner
Inheritance Hierarchy

System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
        Microsoft.SharePoint.WebControls.SPControlDesigner
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.
See Also

Tags :


Community Content

Adam Buenz - MVP
SPControlDesigner

Description

The Microsoft.SharePoint.WebControls.SPControlDesigner sealed class inherits from the System.Web.UI.Design.ControlDesigner class which allows the extension of control design mode behavior. The primary use of SPControlDesigner is when it is necessary to manage control previews within editors, particularly evident when using SharePoint Designer. When used as a System.ComponentModel.Designer class attribute type, combined with inheritance with Microsoft.SharePoint.WebControls.IDesignerEventAccessor interface the control is forced into implementing the call to OnLoad and OnPreRender.

Usage Scenario

The primary usage of SPControlDesigner is when building classes that require control over the design mode behavior since SPControlDesigner is a built into SharePoint designer.
In the below, MyClass is inheriting the IDesignerEventAccessor interface, and implementing the respective members. The OnDesignLoad method is calling the current instance OnLoad and the OnDesignerPreRender is calling the OnPreRender. The Design decorations are also being set to the appropriate type of SPControlDesigner.

C# Code Example

   [Designer(typeof(SPControlDesigner))] 
public class MyClass : Control, IDesignerEventAccessor
{
public void OnDesignerLoad(EventArgs e)
{
this.OnLoad(e);
}

public void OnDesignerPreRender(EventArgs e)
{
this.OnPreRender(e);
}
}

VB.NET Code Example

<Designer(GetType(SPControlDesigner))> _
Public Class [MyClass]
Inherits Control
Implements IDesignerEventAccessor
Public Sub OnDesignerLoad(ByVal e As EventArgs)
Me.OnLoad(e)
End Sub
Public Sub OnDesignerPreRender(ByVal e As EventArgs)
Me.OnPreRender(e)
End Sub
End Class

Page view tracker