locked
EventReceiver. RRS feed

  • Question

  • HI All,

    we have a development requirement as below:

    We have a site collection suppose A. For this site collection we have three different sub sites suppose x,y,z. Each sub site has default page library where the page created is saved.

    The requirement is that when a page is created in subsite x, then that page should also be saved in the page library of subsites y and Z.

    do we any code for implementing the same.

    thanks
    Anitha vyas
    Wednesday, October 14, 2009 11:33 AM

Answers

  • Hi Anitha,

    You will need to write a custom event handler for this and attach it to the page library.

    No other option that i know of.
    HTH, Krishnan
    • Proposed as answer by Muralidharan Palani Wednesday, October 14, 2009 1:37 PM
    • Marked as answer by Chengyi Wu Thursday, October 22, 2009 2:22 AM
    Wednesday, October 14, 2009 12:01 PM

  • For your reference:SPEventReceiverDefinition Class(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverdefinition.aspx)

    The following example uses members of the SPEventReceiverDefinition class to register an ItemAdding event receiver for the Contacts list of a specified Web site.

    string listName = "Contacts";
    string siteURL = "http://Server/Site";
    string receiverName = "Contacts Event Receiver";
    int sequenceNumber = 2001;
    string assemblyFullName = "Assembly_Name, Version=1.0.1777.23493, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5";
    string assemblyClassName = "Assembly_Name.Class_Name";

    SPList list = new SPSite(siteURL).OpenWeb().Lists[listName];
    SPEventReceiverDefinitionCollection eventReceivers = list.EventReceivers;

    SPEventReceiverDefinition eventReceiver = eventReceivers.Add();
    eventReceiver.Name = receiverName ;
    eventReceiver.Type = SPEventReceiverType.ItemAdding;
    eventReceiver.SequenceNumber = sequenceNumber;
    eventReceiver.Assembly = assemblyFullName ;
    eventReceiver.Class = assemblyClassName ;
    eventReceiver.Synchronization = SPEventReceiverSynchronization.Synchronous;

    eventReceiver.Update();


    Keep It Simple and Stupid.
    • Marked as answer by Chengyi Wu Thursday, October 22, 2009 2:22 AM
    Friday, October 16, 2009 12:44 AM

All replies

  • Hi Anitha,

    You will need to write a custom event handler for this and attach it to the page library.

    No other option that i know of.
    HTH, Krishnan
    • Proposed as answer by Muralidharan Palani Wednesday, October 14, 2009 1:37 PM
    • Marked as answer by Chengyi Wu Thursday, October 22, 2009 2:22 AM
    Wednesday, October 14, 2009 12:01 PM

  • For your reference:SPEventReceiverDefinition Class(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverdefinition.aspx)

    The following example uses members of the SPEventReceiverDefinition class to register an ItemAdding event receiver for the Contacts list of a specified Web site.

    string listName = "Contacts";
    string siteURL = "http://Server/Site";
    string receiverName = "Contacts Event Receiver";
    int sequenceNumber = 2001;
    string assemblyFullName = "Assembly_Name, Version=1.0.1777.23493, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5";
    string assemblyClassName = "Assembly_Name.Class_Name";

    SPList list = new SPSite(siteURL).OpenWeb().Lists[listName];
    SPEventReceiverDefinitionCollection eventReceivers = list.EventReceivers;

    SPEventReceiverDefinition eventReceiver = eventReceivers.Add();
    eventReceiver.Name = receiverName ;
    eventReceiver.Type = SPEventReceiverType.ItemAdding;
    eventReceiver.SequenceNumber = sequenceNumber;
    eventReceiver.Assembly = assemblyFullName ;
    eventReceiver.Class = assemblyClassName ;
    eventReceiver.Synchronization = SPEventReceiverSynchronization.Synchronous;

    eventReceiver.Update();


    Keep It Simple and Stupid.
    • Marked as answer by Chengyi Wu Thursday, October 22, 2009 2:22 AM
    Friday, October 16, 2009 12:44 AM