This topic has not yet been rated - Rate this topic

SPControlDesigner Class

System.Object
  System.ComponentModel.Design.ComponentDesigner
    System.Web.UI.Design.HtmlControlDesigner
      System.Web.UI.Design.ControlDesigner
        Microsoft.SharePoint.WebControls.SPControlDesigner

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
public sealed class SPControlDesigner : ControlDesigner
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
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

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com