- Is it possible to restrict users from entering invalid data?
- Is it possible to have counters for files created ,deleted?
- Is it possible to display users with "Custom Error" in case they try entering invalid data?
In WSS 3.0 events that are triggered by list allow you to hook up with code when the list itsms are added,changed or removed.
Events are divided in 2 category :
- Events that fire before an action occurs :This allow you to perform custom validation or processing of data that is about to be added to the list,modified or deleted.
- Events that fire after a certain action occurs
You can create an event handler assembly using Visual Studio .NET by creating a class inhering from SPItemEventReceiver base class present in Microsoft.SharePoint.dll assembly.
public class MyFirstEventhandler:SPItemEventHandler
This class will be instantiated by the WSS 3.0 when action occurs within the list. In order to define custom behaviour of these events we need to override the methods in SPItemEventReceiver class. Following method can be overriden:
public override void ItemDeleting(SPItemEventProperties property)
property.ErrorMessage ="Any amout greater than 500 cannot be deleted" ;
In this case when user tries to delete any item whose Amount is greater than 500 gets an error message .
Now as we have done with the Event assembly the next task is to register the assembly.In my next Blog we can check out the registering of events to a list.