Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Classes Simple Event Handler from the SDK Deployment –Object model.

Similar presentations


Presentation on theme: "Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Classes Simple Event Handler from the SDK Deployment –Object model."— Presentation transcript:

1 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Classes Simple Event Handler from the SDK Deployment –Object model –Features Impersonation

2 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Overview Developers can use event handlers to execute custom code before or after events that happen to site collections, sites, lists, or list items before = synchronous after = asynchronous

3 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Event handlers must derive from an appropriate class and implement specific methods to handle the events correctly: –SPWebEventReceiver – for site and site collection events –SPListEventReceiver – for list schema events –SPItemEventReceiver – for list item events

4 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Classes: SPWebEventReceiver SiteDeleted Occurs after a site collection has been deleted. SiteDeleting Occurs when a site collection is being deleted. WebDeleted Asynchronous after event that occurs after an existing Web site is completely deleted. 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.

5 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Classes: SPListEventReceiver FieldAdded Occurs after a field link is added. FieldAdding Occurs when a fieldlink is being added to a content type. FieldDeleted Occurs after a field has been removed from the list. FieldDeleting Occurs when a field is in process of being removed from the list. FieldUpdated Occurs after a field link has been updated FieldUpdating Occurs when a fieldlink is being updated

6 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Classes: SPItemEventReceiver Only asynchronous methods listed ItemAdded ItemAttachmentAdded ItemAttachmentDeleted ItemCheckedIn ItemCheckedOut ItemDeleted temFileConverted ItemFileMoved ItemUncheckedOut ItemUpdated

7 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Simple Event Handler from SDK 1.Create an event handler for a list item 2.Override ItemUpdating() to show how to display messages to the user 3.Override ItemAdded() to demo asynchronous events

8 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Deployment When event handler is ready, developer must deploy the assembly into GAC (Global Assembly Cache) Then developer must register the event in one of the three ways: –using a feature for a list type –using a feature for a content type –using object model to register to SPWeb or SPList EventReceivers

9 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Deployment 1.Deploy the event handler through the object model 2.Development tips: a.Each time the change is made, remove and add the dll to GAC, and restart IIS. b.The eventsink code should be calling other classes that can be tested separately

10 Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Impersonation in event handlers Event handlers are executed in the context of the current user Use System.Security.Principal.WindowsIdentity to check Certain actions will require impersonation


Download ppt "Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Classes Simple Event Handler from the SDK Deployment –Object model."

Similar presentations


Ads by Google