Today I want to talk about Event Handlers in Share Point 2007.
What is an Event Handler? An event handler is a .Net assembly that contains the additional business logic you need to run when the event occurs in Share Point.
Event handlers are programs that enhance and add functionality throughout Share Point sites and lists, manage events, and be deployed to new and existing sites either by code, such as creating a Project Class to register an event handler, or as part of Feature, Deploying event handlers with Features greatly simplifies the deployment process.
Well, event handlers allow you to add [Something] your business needs into the functionality of Share Point. [Something] examples:
1 ) Retrieve information from a database such as filling in the remaining fields of a list.
2) Call a web service.
3) Start a workflow.
4) Perform list data validation.
5) Convert document to PDF and store in alternative list.
6) Access data in another list.
The events include “before-the fact” or synchronous events as well as “after-the-fact” or asynchronous events. As a developer interested in catching Share Point events, you are no longer limited to only document libraries and form libraries. Now you have the ability to catch events on particularly every list type that Share Point offers, as well as at the site level, list, or library level, and the individual file level
Asynchronous vs Synchronous Events: (The “ing” and “ed”)
As you may have noticed above, there are two events, there are two events raised for each type of event. The “...ing” event occurs before the action starts and the “..ed” occurs after the actions ends. “…ing” events occur synchronously while the “…ed” events occur asynchronously. What does this mean??
Synchronous Events:
Synchronous events, events that activate before an action occurs. An example of a synchronous event is one that can trap an item before it is deleted and remove the ability for users to delete an item, such as a file in a list or document library.
i) Occurs before the event
ii)Block the flow of code execution until your event handler completes.
iii) Provide you with the ability to cancel the events resulting in no after event (“…ed”) being fired.
Asynchronous Events:
Asynchronous events, event that activate after an action occurs, such as appending an item to a list column or sending an email after a file has been uploaded or a list entry has been made.
i) Occurs after the event.
ii) Do not block the flow of code execution in share point.
The share point object model exposes several event classes, which ultimately inherit from the Microsoft.SharePoint assembly and directly inherit from the Microsoft.SharePoint.SPEventReceiverBase class. There are three main event classes.
1) SPWebEventReceiver
2) SPListEventReceiver
3) SPItemEventReceiver
Each class includes both synchronous and asynchronous methods to work with events at the Item, List, or web level.
In my next post I will discuss in depth about SPWebEventReceiver, SPListEventReceiver, SPItemEventReceiver classes and How to create event handlers and registering the event handlers using code.
2 comments:
It is very informative
I am not aware of SharePoint Server, but this article make me sense about Synchronous and Asynchronous events.
simply Gr8.
Post a Comment