This topic has not yet been rated - Rate this topic

IDesignerEventAccessor Interface

Accesses designer events.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
public interface IDesignerEventAccessor
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
IDesignerEventAccessor
Description

The Microsoft.SharePoint.WebControls.IDesignerEventAccessor interface contracts two separate members, the OnDesignerLoad and OnDesignerPreRender methods. IDesignerEventAccessor is crucial when supporting the design time control lifecycle since the ASP.NET ControlDesigner doesn’t call OnLoad or OnPreRender when requesting control preview generation, notable when using SharePoint Designer. Since OnInit and OnPreRender are both protected, the control designer can’t directly call OnInit and OnPreRender. Therefore the interface is used to circumvent this shortcoming.

It should be noted that in legacy versions of SharePoint, the IDesignTimeHtmlProvider interface was used in order to get relevant design elements for design time support provided by a SOAP call. This approach has since been deprecated and should not be used with the current revision of SharePoint.

Usage Scenario

The primary usage of IDesignerEventAccessor is to control the design time control lifecycle. For design time support, IDesignEventAccessor can be used along with the class level System.ComponentModel.Designer attribute set to type SPControlDesigner to support design time services for the component. 

In the below, MyClass is inheriting the IDesignerEventAccessor interface as well as the System.Web.UI.Control to specify that a new ASP.NET server control is being defined. Following, the respective members of the IDesignerEventAccessor interface are implemented. The interface contracted OnDesignLoad method is calling the current control instance OnLoad. The interface contracted OnDesignerPreRender is calling the current control instance OnPreRender. The class design decorations are also being set to the SPControlDesigner type.

C# Code Example

[Designer(typeof(SPControlDesigner))] 
    public class MyClass : WebPart, 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 WebPart
    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 Services MVP - http://www.sharepointsecurity.com