This documentation is archived and is not being maintained.

RegisterForEvent Method

SharePoint 2003

Enables a Web Part to register for a system or custom event.

    RegisterForEvent (NamespaceURN, EventName, Function, UniqueQualifier)

NamespaceURN  A string naming a user-defined namespace that provides a context for resolving event names, object names, and so on.

EventName  A string containing the name of the event for which the Web Part is registering.

Function  A reference to the function to call when the event occurs. You can use the EventObject parameter of the RaiseEvent method to pass values to this function.

UniqueQualifier  Optional. A unique qualifier for the part.

Remarks

The RegisterForEvent method works together with the RaiseEvent method to create a coordinated response among Web Parts. When using this method in Microsoft Visual Basic Scripting Edition (VBScript), you must pass the function using the GetRef function. This ensures that the same pointer is used by both methods. (For information about the GetRef function, see the VBScript documentation in the MSDN library.)

The UniqueQualifier parameter can be useful in situations where the identity of the calling Web Part must be maintained. A typical example is when you have multiple parts registered for the same event and you want the event to fire for each of the parts rather than just once for all the parts. If all three parts are registered for the same event and no qualifier is specified, or if the same qualifier is specified for each part, the event is fired only once for all three parts. If a unique qualifier is provided for each of the parts, the event fires three times.

Web parts can register to receive notifications for standard system events triggered in the browser. The NamespaceURN for these events is "urn:schemas-microsoft-com:dhtml". For a list of standard system events that are supported, see Web Part Page Services Component (WPSC) Overview.

Example

Microsoft Visual Basic Scripting Edition:

WPSC.RegisterForEvent "urn:testchange","onUpdate", GetRef("CheckWebPart")

Microsoft JScript:

WPSC.RegisterForEvent("urn:testchange","onUpdate", CheckWebPart);

Requirements

Platforms: Microsoft Windows Server 2003

RaiseEvent Method | UnregisterForEvent MethodApplies to: WPSC Object

Show: