.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

List Event Receivers firing for all custom lists

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :SharePoint
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

View Complete Post

More Related Resource Links

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.

Custom WebPart .LoadControl(.ascx) event not firing


I am creating a Webpart which loads a custom control (.ascx) in the CreateChildControls Event

        protected override void CreateChildControls(EventArgs e)

            _userControl = Page.LoadControl(@"/_controltemplates/ControlTemplates/CustomUserControl.ascx");
            _userControl.ID = "usrSearchResults";


In the codebehind of this user control (I am using the inherits model as in ASP.NET 1.1) I have an InitializeControls method which binds the eventhandlers to an already existing DropDownList on the user control.

Markup in the .ascx file
    <asp:DropDownList ID="ddlRegions" AutoPostBack="true" runat="server" DataTextField="Title"
        DataValueField="Title" EnableViewState="true">

EventHandling code in the code behind of the user control.  This code runs in every Page_Load event.

ddlRegions.DataBound += new EventHandler(ddlRegions_DataBound);
The problem is that when the selected values in the dropdownlist changes the event handler does not fire (a post does occur though).  Am I missing something here?


Fighting with List Event Receivers


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?


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?


Removing "External List" option from Custom Lists?


We are in the process of upgrading from SharePoint 2007 to SharePoint 2010.  Our business users have noticed a new option of creating a new "External List" under the Custom Lists heading.  Is there any way to remove the External List option without having to customize the create.aspx page?

Andy Kreider | Principal Financial Group | Des Moines, IA, USA

EventReceivers firing on all custom lists


Hi everyone, I've come here as a last resort before I find a revolver and a barn. I've struggled with this problem for weeks, even though it should in theory be a ridiciously simple thing.

My problem is that I have build a eventreceiver in VS2010 which for some reason is triggered on more lists than I specify. When I modifiy a list, the itemadding/added/updated/deleted-event is triggered for all the lists in the site. I don't have a clue why this happens, and I will provide code below. I have looked into the possibility that older versions/eventreceivers have been in action, hence I've deactivated all solutions and all, but a couple of integrated features. I've also started a new project in VS several times, and copied only the code over to the new project.

Obviously I've removed the ListTemplateId from the Receivers in the Elements.xml file. I should mention though, that my eventreceivers were still called even if I didn't assign them to any list in elements.xml, or if I specified ListUrl="myList" for example. The result is that the itemadding/added/updated/deleted-event is triggered for all the lists in the site.

My elements.xml file is as below:

<?xml version

PreSaveAction is not firing for a custom save button on a Custom List Form

Hi Everybody,
I've created a custom list form using SPD. Now I want to put a custom button for saving and redirecting to another page based on a logic. I am using following script for making a custom Save button.

<input type="button" value="Submit" name="Submit" onclick="{ddwrt:GenFireServerEvent('__commit;__redirect={Confirm.aspx}')}  " />
When the user clicks this button, I am able to save the values, but the validation I have implemented in the PreSaveAction() is not getting activated. I don't understand where the problem is.

Is validation with PreSaveAction()  works only with OOB SaveButton ?

Thanks in advance,
- Loka Samastha Sukhino Bhavanthu : May Eternal Peace & Goodwill Prevail in the Whole World!

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?

Event receiver firing wrong list



I have added two eventreceivers to two different lists. But the receivers are firing on both list.
In the element.xml  files ( one for each list) I am adding the receiver to the listdefinition. See below..

When I add an item to any of the two list, the eventreceivers are firing, independent on the list I added the item to.

Does anybody know why?

List 1
<Receivers ListTemplateId="20011">
      <Assembly>AL.Intranet.EventReceivers, Version=, Culture=neutral, PublicKeyToken=0224865009a9e8c5</Assembly>

List 2
  <Receivers ListTemplateId="20020">

SharePoint Event REceivers and Custom Error Messages.

I have an ItemAdding Event Receiver, with the following code fragment

properties.ErrorMessage = string.Format("{0} is already registered for this program.",item["Attendee Name"].ToString()));

properties.Cancel = true;

properties.Status = SPEventReceiverStatus.CancelWithError;


despite of the custom error message being set, I receicve the following error.

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?


Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .

How to add custom list entries to mysite's calendar in Sharepoint 2007 site?


I would like to know below things

(1) How to create MySite for one specific member with other or administrator's access?

(2) Scenario : Administrator have created one SP2007 site. now Administrator have created one calendar (Sample calendar). Administrator have added some entries in calendar. now one user entered in portal site ansd view the calendar and he click on MySite menu. so this sample calendar entries should enter in that user's mysite calendar. How this can be achieved?

Thanks in advance.
Regards, Praful Udade

Picker returns nothing for BDC column in custom list


Playing with the BDC for the first time, running into some issues adding a Business Data column to a custom list.

I believe my ADF file is solid. I've been able to import that just fine and can use the application to drive various BDC-specific webparts (a Business Data List or Business Data Item, for example). It also seems to work when I manually enter information in my NewForm.aspx field and click the Check Names button (it verifies my entry and underlines it, creates link to profile when I view the list data).


If I try to use the picker, I get nothing. Enter a name I know is valid or a % and click the magnifying glass icon and I very briefly get the "Please Wait" message, then just an empty set with "Type into the search box above then press "Enter" to start your search" where my results should be.

Any pointers? Thanks.

SharePoint Designer: insert custom list not working anymore



Suddenly sharepoint designer decided today that it doesn't want to insert a custom list form anymore...
To be more specific, it doesn't work anymore in a site that uses the Microsoft budgeting and tracking template. In a website that uses an out of the box template, it still works.

It did work before, because I did it in other websites using the same template (it's broken there as well now).

Why oh why does SharePoint refuse to do this now?
I searched google and here on the forums, but all I could find was some issues after installing SP1, but we did that already long time ago and it was still working after that. I checked with our infrastructure guys and they didn't install new updates they say.

I also tried the solutions listed here: http://blogs.msdn.com/spdsupport/archive/2008/07/03/how-to-fix-custom-list-forms-will-not-insert-or-show-up-on-the-design-surface-of-sharepoint-designer.aspx
But they don't fix the problem.

So my problem is, I can go to Insert > SharePoint Controls > Custom List Form
I pick my list, content type and form type, I hit OK and... nothing happens.

How to write an event to manage permissions on a document while uploading, depending on custom field



I am trying to find a solution to manage permissions on a document, while uploading it into a document library. This event has to be fired if a custom field is populated (it's a check box field).

How to write an event for this, i tried writing ItemAdded event, but this is getting fired as soon as a document is uploaded, before coming to the page, where we populate all the fields and hit check in.

can i capture Check-in event.

Please advise.


Infopath button click event in custom workflow code.


Hi All,

I have designed the infopath form(Init) and integrated with my state machine workflow. i want to access button click event (designed in Infopath form) in my workflow code.

Can you help me.




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