.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Fighting with List Event Receivers

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :SharePoint

This is what I intend to do:

When a new list item has been added, I want to run some logic and populate some fields programmatically. My first approach was to create a List Item Adding event receiver, however, I cannot "write" to fields via properties.ListItem["field"]. I receive an exception "Object reference not set to an instance of the object".

When I try to implement the same in the "List Item Added" event receiver, it never gets fired.

Any ideas?


View Complete Post

More Related Resource Links

List Event Receivers firing for all custom lists

Hello, I have a site with two custom lists, and I have created an EventReceiver class to handle the ItemAdded event for custom lists. I have modified the EventReceiver's Elements.xml file to only handle items added to one of the custom lists instead of all custom lists, by changing: <Receivers ListTemplateId="100"> to <Receivers ListUrl="/Lists/MyCustomList">   however, when debugging, the ItemAdded method is being fired when an item is added in both custom lists. I have had to work around this by checking within the ItemAdded method for the list that fired the event:        public override void ItemAdded(SPItemEventProperties properties)        {            base.ItemAdded(properties);            if (properties.ListTitle.Equals("My Custom List")) { ... } I thought the ListUrl attribute of the Receivers element specifies the event to only fire for the specific list with that url? (see http://msdn.microsoft.com/en-us/library/ms431081.aspx). Is there somewhere else I should be checking?   Thanks

Item Event Receivers or way to validate data entered for External List in SharePoint 2010?

Hi everyone,

Are there Item Event Receivers for External List in SharePoint 2010? If not, is there a way to validate the item data entered from External List UI in SharePoint site?


Multiple Event Receivers For Single List



I've developed a custom event receiver that fires of the ItemUpdated event for a list. While this code works fine in our dev environment, it appears to not function correctly in production. I have been told that there's another event receiver that also fires on the ItemUpdated event for the same list.

 From the behavior I have seen, it would appear the the two event receivers are "colliding" with one other. Is there anything that I can do to work around this problem? Is there a way to specify an order that the receivers are fired or some other way to prevent them from stepping on each other?

Quick Note: Add Event Receivers to SharePoint 2010 Lists

In this exercise, you add an event receiver to a custom Microsoft SharePoint 2010 list that is triggered when you attempt to delete an item in the list.

Chapter 9: Event Receivers, Part 1 (Expert WSS 3.0 and MOSS 2007 Programming)

Learn to implement your own custom list event handlers and bind them to a list type, list instance, site content type, or list content type.

Chapter 9: Event Receivers, Part 2 (Expert WSS 3.0 and MOSS 2007 Programming)

Learn to implement your own custom item event handlers and bind them to a site content type or a list.

Sharepoint 2010 List Added Event Problem

Hi All, I have created List Added Event Handler. In that Event I want to Add Custom Field in List as List is created. I get an Error "The Specified Program Requires    a newer version of windows" Is there ant solution for it. I have tried it also creating new instances of spweb and spsite rather than getting it from "Properties" Thanks Saumil Thakkar

how to get values of list item being entered in ItemAdding event handler?

Hi,          i am trying to get the values being entered in a listitem in the ItemAdding eventhandler as follows, but it doesnt work. public override void ItemAdding(SPItemEventProperties properties)         {             base.ItemAdding(properties);             SPSite CurrentSite = new SPSite("http://mm-moss/np/");             SPWeb CurrentWeb = properties.OpenWeb();             SPList CurrentList = CurrentWeb.Lists[properties.ListId];             string vehicleNo = CurrentList.Items[CurrentList.Items.Count - 1]["Vehicle No"].ToString();             string  name=CurrentList.Items[CurrentList.Items.Count-1]["Name"].ToString(); } when i debug i cant get hold of the VehicleNo value. canyone help me in getting the values of the list item being entered? Thank you all.

Bind Event Receiver to List Dynamically


Hey all, I've been working on a little application page that will give users the option to say whether a list should allow duplicate title entries.

I am able to pass the current list GUID to the application page using this:

<UrlAction Url="~site/_layouts/preventduplicates.aspx?List={ListId}"/>

within a custom action which I've added to the list settings. I'm kind of stuck now....


I'm not sure how to grab this GUID out of the url, and use it so I can bind the current list with my event receiver. Every example I've seen of binding has used a hard coded list name which is fine as an example, but isn't the best for real applications. Or is there a way to use the GUID to get the lists name which I can then pass to the spweb.Lists[var] ? Since I won't know the list name beforehand.

Hope all of that makes sense, any suggestions are appreciated.

Button On client click event Loads Drop Down List


Hello All


Right now my ASP page has a text box and a submit button, what I am trying to do is once the user hits the submit button load a drop down list.


The drop down list should not be visible before the submit button is pressed


Thanks in advance 

List Event Receiver in Visual Studio 2010 Received "Save Conflict"


Here is the code. ItemUpdated was looped multiple times that caused the error shown below the code.  I Google the error and one suggestion was adding "if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)" will prevent the loop. The problem was both properties.AfterProperties["vti_sourcecontrolcheckedoutby"] and properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] were always null. Any ideas?

Is it possible to update a list item in the ItemUpdating event receiver?


i need to add a property (SPListItem.Properties) to the SPListItem being updated in my ItemUpdating event receiver. is there any way to do that?

SPListItem.Update() doesnt seem to be an option, so the obvious answer is probably trying to use the SPItemEventProperties object called properties by calling properties.AfterProperties.ChangedProperties.Add(key, value) and letting sharepoint do the rest, but it turns out it actually deals with fields and not properties. it's a little misleading. so is there another way? some kind of painful work around maybe?

Disable all day event in Calendar list

Hi there,

Is there anyway of disabling the All day Event field in a Calendar list. I don't have the option to hide it either.

Event Receiver für WorkflowCompleted event - How to get list item?



I'm using an event receiver, which reacts on the WorkflowCompleted event (which is new in SharePoint 2010). In general the event is fired, when an associated workflow has been completed. The question is: how to get the list item the workflow is running against? The WorkflowCompleted event handler has a parameter of type SPWorkflowEventProperties, but via those properties I can't access the specific list item.

Any Idea how to achieve this?




Calendar Web Part for SharePoint that displays and gives fetails of events from an event list: Value

Hi All,

         I have followed the following post to create the custom Calendat webpart, that displays the details of events from events list. 

But i am getting the following error when i click on the dates shown as there are some events. The error looks like the following,

Server Error in '/' Application.

Value does not fall within the expected range. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Value does not fall within the expected range.

Source Error: 

How to delete the default columns( All day Event field ) from the Calendar List in sharepoint?



Is there anyway of disabling the All day Event field in a Calendar list. I don't have the option to hide it either.

Any help appriciated...


Srikanth Reddy

How to disable "All day event" of Calendar list in email alerts ?




I have hidded the All day event in display, edit, new forms using javascript code.

I want to hide the "All Day Event","Recurrence",Workspace of calendar list in email alerts



Srikanth Reddy


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend