0

What Event in Event Receiver should I use to catch the item uploading event? Seems that ItemAdding or ItemAdded can not catch the event

  • What do you want in document uploading event can you brief it – Sunil Sahu Sep 4 '18 at 12:29
1

First of all, which environment are you using, 2007, 2010 or 2013?

Here's a generic explanation: ItemAdding fires before the item is added, which means you can get the object before it is added to the list. You can use HttpContext to do this. This gives you the opportunity to show an error message and abort if something doesn't look right.

When the ItemAdded event is fired, the object is already in the list and you can manipulate it if you want to. Hope this helps.

1

uploading with the following code, the file being uploaded won't be added into library. so same can be used to catch the event.

class ShareDocEventHandler : SPItemEventReceiver
{
HttpContext htcntxt = null;
public ShareDocEventHandler()
{
  htcntxt = HttpContext.Current;
}

public override void ItemAdding(SPItemEventProperties properties)
{

  base.ItemAdding(properties);
  properties.Cancel = true;

}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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