SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom list which I have written a SPItemEventReciever for and it works. But when I do the same for a document library it doesn't fire. Is there anything I have to do if it is a document library?

Sample code below.

public class OrderHandler : SPItemEventReceiver { public override void ItemAdded(SPItemEventProperties properties) { GenerateID(properties); }

public override void ItemUpdated(SPItemEventProperties properties) { GenerateID(properties); }

void GenerateID(SPItemEventProperties properties) { SPListItem order = properties.ListItem;

string customer = order["Customer"].ToString(); string orderDate = Convert.ToDateTime(order["OrderDate"]).ToShortDateString();

order["OrderID"] = customer + " " + orderDate; order.Update();

} }

Do I need to treat a list different if it's a document library?

share|improve this question

Have a look through this list of Event Receiver Troubleshooting hints:

I think you might want to disable event firing before updating a list item, though.

share|improve this answer
Thanks.If i want to rename the filename when uploading a document.Should i be looking at ItemsAdded or ItemUpdating?? – Patrick Nov 15 '10 at 13:05
ItemAdded, change the AfterProperties and disable event firing so ItemUpdating isnt called immediately after,too. – James Love Nov 15 '10 at 14:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.