Académique Documents
Professionnel Documents
Culture Documents
Page 1 of 19
Brian Wilson!
Best Practices, advice and guidance on all things related to SharePoint Technologies.
RSS 2.0
Atom 1.0
Home
About
Email
Search
Go
Tags
architecture
branding
CodePlex
Deployment
development
Event Handlers
Features
field
General
How To
infrastructure
integration
language pack
list definition
list template
MOSS 2007
MOSS Custom Admin Pages
Search
site definition
site template
Starter Kit
UK SharePoint Team
user experience
Web Parts
WSS
News
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 2 of 19
Facebook Profile
Linked In Profile
Follow me on Twitter
All of my postings are my own opinion, are provided "AS IS" with no warranties, and confer no rights.
Use of included samples are subject to the terms specified at Microsoft.
Archives
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 3 of 19
Blogs :: Cool
Martin Fowler
Rocky Lhotka
Magazine : New Scientist
Blogs :: SharePoint
Joel Oleson
Mauro Cardarelli
Andrew Connell - WCM - (MVP)
Mark Kruger
Nick Swan UK (MVP)
Bill English (MVP)
Mike Watson
Heather Solomon
Spence Harbar (MVP)
Todd Klindt
Office Rocker
Mark Harrison
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 4 of 19
Post 3: Registering Event Handlers plus Site Settings - Manage Event Handlers
Overview
Today I want to talk in depth about a feature of Microsoft Office SharePoint Server
2007 (MOSS) that shows you just how extensible the SharePoint 2007 platform is!
That feature is the ability to add custom event handlers to sites, lists, items and
content types in your portal.
What is a custom event handler? A custom event handler is a .Net assembly that
contains the additional business logic you need to run when the event occurs in
SharePoint.
Why did I pick this feature? Well, no portal or business application ever really lives
in isolation to your other Line of Business (LOB) applications, and shouldn't! Your
portal solution needs to be dynamic, expect change and work seamlessly with the
other systems in your environment. So, you may ask, what does this have to do
with Event Handlers?
Well, event handlers allow you to add [SOMETHING] your business needs into the
functionality of SharePoint. [SOMETHING] examples:
The possibilities around writing custom event handlers to perform an action based
on an event in SharePoint 2007 are endless!
Event Types
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 5 of 19
WebDeleting Synchronous before event that occurs before an existing Web site is
completely deleted.
WebMoved Asynchronous after event that occurs after an existing Web site has
been moved.
WebMoving Synchronous before event that occurs before an existing Web site has
been renamed or moved to a different parent object.
FieldDeleted Occurs after a field has been removed from the list.
FieldDeleting Occurs when a field is in the process of being removed from the
list.
ItemAdded Asynchronous After event that occurs after a new item has been
added to its containing object.
ItemAdding Synchronous before event that occurs when a new item is added to
its containing object.
ItemAttachmentDeleted Asynchronous after event that occurs when after a user removes
an attachment from an item.
ItemCheckedIn Asynchronous after event that occurs after an item is checked in.
ItemCheckedOut Asynchronous after event that occurs after an item is checked out.
ItemCheckingIn Synchronous before event that occurs as a file is being checked in.
ItemCheckingOut Synchronous before event that occurs after an item is checked out.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 6 of 19
ItemFileConverted
Synchronous events:
• Occur before the event.
• Block the flow of code execution until your event handler completes.
• Provide you with the ability to cancel the events resulting in no after event
(“...ed") being fired.
Asynchronous events:
• Occur after the event.
• Do not block the flow of code execution in SharePoint.
Content Type is just what it sounds like: a metadata description of content that
can include custom properties, a retention policy, and an associated set of
workflows and business processes.
For example, a company may define a “Contract” Content Type that includes the
required metadata to make it easy to find that contract later.
The “Contract” Content Type is now a metadata description definition that can be
associated to lists such as Document Libraries in your SharePoint environment.
Once added, you now have the ability to add and manage Contracts added to your
portal.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 7 of 19
This is where Event Handlers come in: You can attach custom event handlers to a
Content Type! Once attached to the Content Type definition, it picks up the events
wherever you use the content type. This is extremely powerful! Why? Well, you
have the ability to target individual content types across the entire site collection.
For example, wherever a “Contract” Content Type is used, you could store a link in
another system for each Contract created in your system, no matter what
document library the contract is stored in.
Best Practices
When building custom event handlers, keep the following points in mind:
1. Security:
The assembly you deploy to the Global Assembly Cache(GAC) is running with full
trust. Watch out for the following:
2. Performance:
Watch out for the following:
• Load: What burden are you placing on your web front end servers to run
the assembly each time an event occurs? Use performance counters to
determine this.
• Long Running Operations: Consider creating a custom SharePoint timer
job. Kick off/ Schedule the Timer Job from the event rather than running all
the logic inside the event. This will allow you to use the features of
SharePoint to view whether the Timer Job ran successfully.
• Sync vs Async Events: Synchronous events have to wait until your code
completes before returning the page, whereas Asynchronous events show
the page immediately.
3. Error Handling:
When using synchronous events and you decide to cancel an event, let the user
know why the event was cancelled. For example, update a Task List with a
message why it failed.
Log your errors so that you can determine what issue is occurring when your
system is in production environment.
4. Connections: Cater for external systems being down when you are trying to
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 8 of 19
connect to them. Don’t let your code / solution go belly up because you cannot
connect to a database.
5. Bulk Operations:
The MSDN documentation mentions that event handlers will not fire when bulk
operation is occurring. For example, when a new list is created, the FieldAdding
event will not fire.
Summary
Custom Event handlers are a powerful tool in your arsenal as a SharePoint
Architect/ Developer!
Filed under: WSS, MOSS 2007, Event Handlers, CodePlex, Starter Kit, How To
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Comments
# Brian Wilson's Blog : Part 1: Event Handlers: Everything you need to know about Microsoft
Office SharePoint Portal Server (MOSS) Event Handlers.
Monday, March 05, 2007 5:21 AM by Brian Wilson's Blog : Part 1: Event Handlers: Everything you
need to know about Microsoft Office SharePoint Portal Server (MOSS) Event Handlers.
Brian Wilson has started a nice series on event handlers in SharePoint 2007, first episode: Everything
# re: Part 1: Event Handlers: Everything you need to know about Microsoft Office SharePoint
Portal Server (MOSS) Event Handlers.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft O... Page 9 of 19
Have you any experience with the ContextEvent? Its mentioned as an item level event in the SDK, but i
can find zero documentation on it :-s
# re: Part 1: Event Handlers: Everything you need to know about Microsoft Office SharePoint
Portal Server (MOSS) Event Handlers.
"Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint Portal Server
(MOSS) Event Handlers
to keep all three nicely lined up as Event Handler articles rather than as articles about Part1; Part 2 and
Part3.
Mike Walsh
# WSS FAQ - additions and corrections - XXXXV 4th - 11th March 2007
Sunday, March 11, 2007 4:34 AM by Mike Walsh's WSS and more
# WSS FAQ - additions and corrections - XXXXV 4th - 11th March 2007
Sunday, March 11, 2007 4:36 AM by Mike Walsh's WSS and more
# SharePoint Kaffeetasse 02
Entwicklung Create a link that opens in a new window in SharePoint 2007 Event Handler Part 1:
Everything
# re: Part 1: Event Handlers: Everything you need to know about Microsoft Office SharePoint
Portal Server (MOSS) Event Handlers.
Come on Brian - time for part 2 by now - i know you don't have much work to do.
# Event Handlers - Part 2: Building and Deploying Event Handlers (Including Event Handler
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 10 of 19
This post is the second post of a 3 post series. Post 1: Everything you need to know about MOSS Event
# Event Handlers - Part 3: Register Event Handlers plus free Site Settings – Manage Event
Handlers Add-on solution
This post is the third post of a 3 post series. Post 1: Everything you need to know about MOSS Event
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Portal Server (MOSS) Event Handlers.
This is a very useful article. What I'd really like, however, is an event handler at the web site level, so
that I can do something whenever a Survey is added to the site. Is this possible?
(Si vous êtes novice sur les event handler, regarder à la fin du post ) En parcourant les forums
SharePoint,
# MOSS Sample : une bon exemple d'Event Handler (gestion des permissions)
(Si vous êtes novice sur les event handler, regarder à la fin du post ) En parcourant les forums
SharePoint,
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I have been trying to use event handlers. I got simple examples working, but when I extend the code to
call a service (WCF) or insert something in a database (ADO.NET) it seems as if my code isn't even run
anymore. Any ideas?
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
The hyperlink that should be pointing at part 2 of your series is pointing to part 1! Please fix it.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 11 of 19
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Hi,
This can't be EVERYTHING we need to know about MOSS event handlers because I need to know
what the ContextEvent is (as AndersR also asked). The ContextEvent doesn't appear in your
SPItemEventReciever lists, but this is event type definitely exists.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Hi Brian,
Thanks for your article on Event Handlers. I have a typical requirement where i need to rename the file
before it got uploaded to sharePoint. Ideally sharepoint does not allow files with illegal characters like #
in SPS##faq.doc. I would like to remove those illegal characters so that sharepoint can accept this file as
SPSfaq.doc.
I would like to hear your comments on this. If you have any better solution other event handlers like
using javascript, that will also be helpful.
phani.
In my previous post, I described the current state of event handlers in MOSS and WSS v3. Also, I listed
I have been asked a few times if it is possible to associate different Content Types with different folders
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 12 of 19
I have been asked a few times if it is possible to associate different Content Types with different folders
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
hi,
i wrote a event handler and put it into my MOSS 2007, after i run some unit test cases, i found some
libraries and lists won’t fire event, following is the list of those lists:
- Slide Library
- Report Library
- Project Tasks
- KPI List
# SharePoint Kaffeetasse 16
Anpassung How to create your own custom wiki site definition Create a KPI List in WSS 2.0/3.0
Customizing
# SPPD075 SharePointPodcast
Direkter Download: SPPD-075-2007-07-27 Diesmal nur mit kurzen Shownotes Buchtipps Microsoft
Office SharePoint
# SPPD075 SharePointPodcast
Direkter Download: SPPD-075-2007-07-27 Diesmal nur mit kurzen Shownotes Buchtipps Microsoft
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 13 of 19
Office SharePoint
# SharePoint Kaffeetasse 16
Anpassung How to create your own custom wiki site definition Create a KPI List in WSS 2.0/3.0
Customizing
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I am trying to get a dataset from OracleDatabase in ItemAdded event. While debugging the point of
execution doesnot return back to code after the command dataadapter.fill(ds), straightway the sharepoint
page comes up and there is no error or exception thrown. I am not sure abt the data whehter it is
obtained in ds or not.please someone help me to solve this.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I think Brian you can continue with this: "how to create a counter wich counts how many times a
document is opened in Sharepoint" :D ... Actually this is my problem... so if somebody can help me with
this ...
plz
tintasbarnes@gmail.com
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
are there any events on user logged in or logged out from a SharePoint site?...i need them for showing
Who's Online webpart.
Any help.Thanks.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 14 of 19
How can I overcome the limitations of Event Handler in SharePoint (WebAdding &WebAdded).The
ActivateOnDefault attribute of the feature does not apply to site collection (Site) or Web site (Web)
scoped Features.
In the event of an Event Handler , don’t try to do anything "fancy". Why? Because SharePoint doesn't
# Event Handlers
Brian Wilson napisal celkom pekny 3 dielny serial. Post 1: Everything you need to know about...
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Avec tout les posts sur codes-sources concernant le d�E9;ploiement sous SharePoint, je pense que
# SPPD075 SharePointPodcast
Direkter Download: SPPD-075-2007-07-27 Diesmal nur mit kurzen Shownotes Buchtipps Microsoft
Office SharePoint
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I'm using WSS 3.0 anda I need to fire the ItemAdded event in a forms library, but when I submit am
infopath form to that library the event is not fired.
I also tried to make a test which consisted in disable the delete item in a library but the event
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 15 of 19
ItemDeleting only works in document library, in forms library nothing works. Any idea?
Below is a list of events that you can hook into: · Microsoft.SharePoint.SPWebEventReceiver : "Site
Level"
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Tnx in advance
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I found it ...
http://blogs.msdn.com/brianwilson/archive/2007/03/18/event-handlers-part-2-building-and-deploying-
event-handlers-including-event-handler-starter-solution-kit.aspx
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Can you help me for the ContextEvent? As it is given in in SDK as an item level event but no
description..
Thanks in Advance......
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
the events in the user control are not firing in MOSS please give me a solution.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 16 of 19
Hi,
And I am getting null error when I try to access the filename in EH - ItemAdding .
Thanks,
Dev
soumendra.dev@gmail.com
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
hi,
while list loading i want to change certain fields text. for example changing the date format.
I would like to know is there any event like rowdatabound of asp.net gridview control.
Regards,
Sankar.
gowrisankar.pokuri@gmail.com
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Hi Brian,
Great first post. Just a heads-up that the link to Post 2 currently points to this post.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 17 of 19
deploying-event-handlers-including-event-handler-starter-solution-kit.aspx
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Hi Brian,
Great post. I however, had a question, I have a dropdown on NewForm.aspx page of a list. I am
customizing it. I wanted to place an event for SelectedIndexChanged for this drop down, and call
another method to get some details and fill other boxes. How do I render event for this dropdown?
Skoro MOSS/WSS jest aplikację Web napisaną w .NET, można by przypuszczać iż wywołanie:
HttpContext .Current.Session
晃晃晃晃晃SharePoint晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃晃SharePoint晃
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I have to track the changes made on a word content(when its opened in ms-office), for that I need to
handle shortterm checkin event. but ItemCheckedIn event is fired only when its checked out in Long
term Checkout. any idea on this...
thanx.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
A question on 'Limitations of Event Handler in SharePoint' which you have specified in this article.
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 18 of 19
Could you please elaborate more on how to use "FeatureActivated" method to capture an event when
site is created?
Thanks,
Charan
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
I have requirement. When we manage permission of the list item it should fire the event so that I can put
my custom code in that even. I donot find any event for Manage Permission. Please suggest.
# re: Event Handlers - Part 1: Everything you need to know about Microsoft Office SharePoint
Server (MOSS) Event Handlers.
Hi,
I am using some unsigned Project DLL (like Common,etc..) inside my event receiver class library.
When i am trying to deploy my DLL, its also ask for the deployment of 'Common' project DLL at GAC
but as the project is referring some unsigned DLL ,i can' make that project to signed and so enable to put
that it's in GAC.
Do it possible that i not require to deploy the DLL to GAC and can work with DLL by placing only it in
'Application's Bin' folder.
Thanks
Leave a Comment
Name (required)
Comments (required)
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009
Brian Wilson! : Event Handlers - Part 1: Everything you need to know about Microsoft... Page 19 of 19
Remember Me?
Submit
© 2008 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy
Statement
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-y... 1/20/2009