Sharepoint 2010中的事件接收器捕获附件

时间:2012-06-01 14:01:00

标签: sharepoint sharepoint-2010

我想捕获列表项中的附件以检查文件长度及其扩展名。我创建了一个SPItemEventReceiver类,并重写了SPItemEventReceiver.ItemAttachmentAdding方法。但是,添加附件时不会触发事件。

什么时候会被解雇?如何检查文件长度和扩展名?

我的EventHandler类:

public class EventReceiver : SPItemEventReceiver
{
   /// <summary>
   /// An attachment is being added to the item.
   /// </summary>
   public override void ItemAttachmentAdding(SPItemEventProperties properties)
   {

       //some code here

       base.ItemAttachmentAdding(properties);
   }
}

我的Element.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="100">
      <Receiver>
        <Name>EventReceiverItemAttachmentAdding</Name>
        <Type>ItemAttachmentAdding</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>EventReceiver.EventReceiver</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
  </Receivers>
</Elements>

0 个答案:

没有答案