So the only way to get all the receivers attached to our list was by creating a console program that would list out all the associated event receivers.
Here is a qucik program that would list out all the receivers associated with a list -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace EventViewer
{
class Program
{
string siteURL = "http://SPSite";
string listName = "Custom List";
static void Main(string[] args)
{
Program p = new Program();
p.PrintAllEvRecv();
}
//Prints all the Event Receivers attached to a list
public void PrintAllEvRecv()
{
using (SPSite site = new SPSite(siteURL))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[listName];
int i = list.EventReceivers.Count;
SPEventReceiverDefinitionCollection eventReceivers = list.EventReceivers;
foreach (SPEventReceiverDefinition ev in eventReceivers)
{
Console.WriteLine("Type=" + ev.Type.ToString() + "\t Class=" + ev.Class.ToString()+"\t Name: " + ev.Name );
Console.WriteLine(" ");
}
}
}}}
}}
Ads by Google
No comments:
Post a Comment