Microsoft.SharePoint.WebCon ...


IPreRenderOverride Interface (Microsoft.SharePoint.WebControls)

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

Visual Basic (Declaration)
Public Interface IPreRenderOverride
Visual Basic (Usage)
Dim instance As IPreRenderOverride
C#
public interface IPreRenderOverride
See Also

Tags :


Community Content

Adam Buenz - MVP
IPreRenderOverride

Description

The Microsoft.SharePoint.WebControls.IPreRenderOverride interface is meant to enforce interface implementation of the PreRender event. This is most important when working with controls that use AJAX, since the event has implications that affect the functionality of extender controls.

The IPreRenderOverrride interface structure is trivial. When being used as a base interface for inheritance, it demands that the OnPreRenderOverride member be implemented. The OnPreRenderOverride has one System.EventArgs parameter which contains the event data.

It should be noted that when using this interface, the base OnPreRender(EventArgs) method should be invoked in order to ensure that script blocks and services are correctly handled for partial-page rendering.

Usage Scenario

The heaviest representation of the IPreRenderOverride interface within the shipped software is in script dependent controls such as Microsoft.SharePoint.WebControls.Menu. However, as a trivially simple interface it is completely possible to use within your custom code by inheritance. The primary usage of the class is when a custom class requires that script blocks are handled correctly during the PreRender stage in order to support partial-page updates.

In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class as well as the the IPreRenderOverrride interface. From this interface, the contracted OnPreRenderOverride is being implemented. Within the implemented OnPreRenderOverride, we are calling the base class OnPreRender from the derived class. Calling the base class OnPreRender method is important regardless of future modifications, otherwise the WebPart will be prone to losing handlers.

C# Code Example

public class MyClass : WebPart, IPreRenderOverride
{
public void OnPreRenderOverride(EventArgs arguments)
{
base.OnPreRender(arguments);
}
}

VB.NET Code Example

Public Class [MyClass]
Inherits WebPart
Implements IPreRenderOverride
Public Sub OnPreRenderOverride(ByVal arguments As EventArgs)
MyBase.OnPreRender(arguments)
End Sub
End Class
Tags :

Page view tracker