Sunday, February 7, 2010

Event Handler in sharepoint 2007

Here we see about how to create Event Handler in Sharepoint 2007.

Steps:

1) Open Visual Studio -> New Project -> Class Library:


2) Include the Reference.


3) Write the Using Microsoft.Sharepoint;


4) Use the same class name or change the class name if you want.


5) Add the method for deleting event:

write public override void give the space and you will get the methods and select which one you want.


6) Write the code for deleting.


7) Click the project properties and select Signing:


8) Tick the check box and select new.


9) Give the Name which you want. And disable the check box.

If you are not giving signing you will get error while creating assembly. Like "Failure adding assembly to the cache."


10) Then Build the project.


11) Create the assembly:
c:\Program Files\Microsoft Sdk's\Windows\V6.0A\bin>gacutil.exe /i give the path here where your project stored\select .dll

See the image below.


12) Create one folder and give any name and copy Elements.xml and Feature.xml into the folder.



13) Get the Public key token from the windows assembly.


14)Create the Elements.xml and Copy the assembly and paste it, give the namespace name and class name.

see the image:


15) Get the Id.


16) Copy the id from the tool bar.


17) Create Feature.xml. Paste that id in the Feature.xml.

See the image:


18) Copy the Entire xml folder and paste that into c:\Program Files\common Files\Microsoft Shared\Web Server Extensions\12\Template\Features.


19) Install the Feature:

c:\Program Files\common Files\Microsoft Shared\Web Server Extensions\12\bin>stsadm.exe -o installfeature -name EventDelete


19) Activate Feature:

c:\Program Files\common Files\Microsoft Shared\Web Server Extensions\12\bin>stsadm.exe -o activatefeature -name EventDelete -ulr http://servername:43380/


20) Go to shared documents and create upload any files. Now you try to delete.



21) Delete Event is now working. You are not able to delete any file from the shared documents.






Thanks,
Ashok Anbarasu.


No comments:

Post a Comment