Skip to main content
expanded answer
Source Link
Benny Skogberg
  • 25.5k
  • 12
  • 68
  • 163

Can't you do it from code behind instead? Like the following:

using (SPSite site = new SPSite("http://localhost")) 
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists["Shared Documents"];

                SPEventReceiverDefinition def = list.EventReceivers.Add();

                def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=704f58d28567dc00";
                def.Class = "ERDefinition.ItemEvents";
                def.Name = "ItemAdded Event";
                def.Type = SPEventReceiverType.ItemAdded;
                def.SequenceNumber = 1000;
                def.Synchronization = SPEventReceiverSynchronization.Synchronous;
                def.Update();
            }
        }

Reference: Binding an Event Handler by Using the SharePoint Object Model


Edit:

Maybe you can try parts of this script, where you access a list via jQuery?

jQuery client list access

Reference: SharePoint list access – Part III – How to access SharePoint Windows Communication Foundation (WCF) REST (Representational State Transfer) services using jQuery (entirely client side only).

Can't you do it from code behind instead? Like the following:

using (SPSite site = new SPSite("http://localhost")) 
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists["Shared Documents"];

                SPEventReceiverDefinition def = list.EventReceivers.Add();

                def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=704f58d28567dc00";
                def.Class = "ERDefinition.ItemEvents";
                def.Name = "ItemAdded Event";
                def.Type = SPEventReceiverType.ItemAdded;
                def.SequenceNumber = 1000;
                def.Synchronization = SPEventReceiverSynchronization.Synchronous;
                def.Update();
            }
        }

Reference: Binding an Event Handler by Using the SharePoint Object Model

Can't you do it from code behind instead? Like the following:

using (SPSite site = new SPSite("http://localhost")) 
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists["Shared Documents"];

                SPEventReceiverDefinition def = list.EventReceivers.Add();

                def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=704f58d28567dc00";
                def.Class = "ERDefinition.ItemEvents";
                def.Name = "ItemAdded Event";
                def.Type = SPEventReceiverType.ItemAdded;
                def.SequenceNumber = 1000;
                def.Synchronization = SPEventReceiverSynchronization.Synchronous;
                def.Update();
            }
        }

Reference: Binding an Event Handler by Using the SharePoint Object Model


Edit:

Maybe you can try parts of this script, where you access a list via jQuery?

jQuery client list access

Reference: SharePoint list access – Part III – How to access SharePoint Windows Communication Foundation (WCF) REST (Representational State Transfer) services using jQuery (entirely client side only).

Source Link
Benny Skogberg
  • 25.5k
  • 12
  • 68
  • 163

Can't you do it from code behind instead? Like the following:

using (SPSite site = new SPSite("http://localhost")) 
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists["Shared Documents"];

                SPEventReceiverDefinition def = list.EventReceivers.Add();

                def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=704f58d28567dc00";
                def.Class = "ERDefinition.ItemEvents";
                def.Name = "ItemAdded Event";
                def.Type = SPEventReceiverType.ItemAdded;
                def.SequenceNumber = 1000;
                def.Synchronization = SPEventReceiverSynchronization.Synchronous;
                def.Update();
            }
        }

Reference: Binding an Event Handler by Using the SharePoint Object Model