SPListItem事件接收器不执行ItemAdded事件

时间:2011-04-26 10:34:02

标签: sharepoint-2010 event-receiver

我使用SharePoint 2010和Visual Studio 2010创建了一个项目事件接收器。事件接收器执行ItemDeleting但它无法执行ItemAddingItemAdded个事件。

我的问题是我以编辑形式上传项目的图像,所以我想在添加新项目后打开编辑表单,所以我假设我可以在项目的Added事件中重定向到编辑页面。

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">   
   <Receivers ListTemplateId="10002">
      <Receiver>
        <Name>SharedItemListEventRecieverItemDeleting</Name>
        <Type>ItemDeleting</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>     
        <Class>ListDefinitions.ListsEventRecievers.SharedItemListEventReciever.SharedItemListEventReciever</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
    </Receivers>
 </Elements>`

1 个答案:

答案 0 :(得分:2)

对于事件接收器触发ItemAdding和ItemAdded,您需要更改elements.xml,如下所示:

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">   
   <Receivers ListTemplateId="10002">
      <Receiver>
        <Name>SharedItemListEventRecieverItemDeleting</Name>
        <Type>ItemDeleting</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>     
        <Class>ListDefinitions.ListsEventRecievers.SharedItemListEventReciever.SharedItemListEventReciever</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>

     <Receiver>
        <Name>SharedItemListEventRecieverItemDeleting</Name>
        <Type>ItemAdding</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>ListDefinitions.ListsEventRecievers.SharedItemListEventReciever.SharedItemListEventReciever</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>

     <Receiver>
        <Name>SharedItemListEventRecieverItemDeleting</Name>
        <Type>ItemAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>     
        <Class>ListDefinitions.ListsEventRecieverSharedItemListEventReciever.SharedItemListEventReciever</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>

    </Receivers>
 </Elements>

`