locked
How to add logic for only specific sharepoint lists. RRS feed

  • Question

  • Hi,

    Please tell me how we can add logic for only specific lists.

    I have created calander lists and the requirement is to add logic for the specific calander list.

    I have implemented above logic but it gets called for each and every calander list.

    Waiting for your reply.

    Thanks in advance,
    Anonymous
    Thursday, May 21, 2009 11:33 AM

Answers

  • You can create a feature receiver to add the event receiver to the specific calendar list.  The feature receiver needs a class inheriting from SPFeatureReceiver and you need to implement the featureactivated event.

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWeb web = properties.Feature.Parent as SPWeb;
        web.Lists["MyCalendar"].EventReceivers.Add(
          SPEventReceiverType.ItemAdded,
          "Dhunter.SharePoint.Eventhandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0a26195ff03df1fd",
          "Dhunter.SharePoint.Eventhandlers.RatingSummaryEventHandler");
    }

    For more info http://www.davehunter.co.uk/Blog/Lists/Posts/ViewPost.aspx?ID=69

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Thursday, May 21, 2009 11:40 AM
  • Thamizh,

    You don't answer the question correctly.  Anonymous wants to know how you can bind a event receiver to a specific list, by using a feature and elements.xml you cannot assign to a specific list only a list type which he/she already has done.

    Anonymous - If you are still having problems and don't want to write code, have a look at this http://www.codeplex.com/spstipsUtilityPack it has a list event management section where you can add event receivers to specific lists or delete them.

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Tuesday, May 26, 2009 8:32 AM

All replies

  • You can create a feature receiver to add the event receiver to the specific calendar list.  The feature receiver needs a class inheriting from SPFeatureReceiver and you need to implement the featureactivated event.

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWeb web = properties.Feature.Parent as SPWeb;
        web.Lists["MyCalendar"].EventReceivers.Add(
          SPEventReceiverType.ItemAdded,
          "Dhunter.SharePoint.Eventhandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0a26195ff03df1fd",
          "Dhunter.SharePoint.Eventhandlers.RatingSummaryEventHandler");
    }

    For more info http://www.davehunter.co.uk/Blog/Lists/Posts/ViewPost.aspx?ID=69

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Thursday, May 21, 2009 11:40 AM
  • This may help you. Just have a try..

    Step 1: Create a class library in VS 2005/2008 and extend the class with ItemEventReceiver class of Microsoft.SharePoint.dll. Then add your logic inside the functions of ItemEventReceiver.

    Step 2: Add a Feature.xml and Element.xml file to define the EventReceiver logic. After that copy the 2 xml files and put them under the 'Features' folder of 12 Hive.

    Step 3: Now using the STSADM.exe utility, install your Custom Feature and Activate  it only for the Calendar list to which u need to associate.

    Step 4: Jus enter iisreset command from the cmd prompt to reset your IIS.

    Step 5: Check out the Calendar list and enjoy


    -Thamizh http://thamizharasi.blogspot.com
    Sunday, May 24, 2009 3:57 PM
  • Thamizh,

    You don't answer the question correctly.  Anonymous wants to know how you can bind a event receiver to a specific list, by using a feature and elements.xml you cannot assign to a specific list only a list type which he/she already has done.

    Anonymous - If you are still having problems and don't want to write code, have a look at this http://www.codeplex.com/spstipsUtilityPack it has a list event management section where you can add event receivers to specific lists or delete them.

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Tuesday, May 26, 2009 8:32 AM