문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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;

}
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top