RegisterForEvent Method
Applies to: SharePoint Foundation 2010
Enables a Web Part to register for a system or custom event.
RegisterForEvent (NamespaceURN, EventName, Function, UniqueQualifier)
Parameters
Parameter |
Description |
---|---|
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 fires 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) Object Model.
Example 1: Microsoft Visual Basic Scripting Edition
Code
WPSC.RegisterForEvent "urn:testchange","onUpdate", GetRef("CheckWebPart
Example 2: Microsoft JScript
Code
WPSC.RegisterForEvent("urn:testchange","onUpdate", CheckWebPart);
Requirements
Applies to: WPSC Object