13 May 2009

Registing Event Handler on a list/library

for Registering the Event Handler following are the steps to be followed:

  1. Add a Console application project in the Event Handler applcation.

  2. Add the DLL of Event Handler in the GAC.

  3. Now include the following code the console application.

static void Main(string[] args)

string AssembleInfo="EventHandlerRegister, Version=, Culture=neutral, PublicKeyToken=d53fad3f8a2d2037" ;
String ClassName="Akshaya.EventHandlerRegister";
http://registerSite/Sites/site, "MYCustomListName", AssembleInfo, ClassName);
Console.WriteLine("Event Registered Successfully......");
catch (Exception ex)

Function for registering this Handler
private static void RegisterEvent(string SiteUrl, string ListName, string AssemblyInfo, string ClassName)
using (SPSite mySite = new SPSite(SiteUrl.Trim()))
SPWeb MyWeb = mySite.OpenWeb();
SPList MyList = MyWeb.Lists[ListName];
//include the event handler you have overrided in your handler.ex her is Itemadded
MyList.EventReceivers.Add(SPEventReceiverType.ItemAdded, AssemblyInfo, ClassName);


now check the list event firing and incorportating those changes.
Thanks: Akshaya

No comments:

Post a Comment

Thanks for your valuable comments

Rate Now: