문제

I have a List Template DocLibTemplate with FeatureId : {00BFEA71-E717-4E80-AA17-D0C71B360101}. I am trying to have a event receiver subscribe to all libraries of this type. This is the code I have for the Elements.xml file for the event receiver.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="101">
    <Receiver>
      <Name>EventReceiver1ItemAdded</Name>
      <Type>ItemAdded</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>SharePointProject7.EventReceiver1.EventReceiver1</Class>
      <SequenceNumber>10000</SequenceNumber>
    </Receiver>
  </Receivers>
</Elements>

From my undesrtanding specifying that ListTemplateId="101" means the event handler will subscribe to Document Libraries. Is there a way to have it subscribe to only Document Libraries that use the DocLibTemplate either through the TemplateID of the template or the FeatureID, or can I create a new ContentType and have the list subscribe to that?

Edit : I found the xml file for the list template by downloading the list template stp file and unarchiving that. This had the manifest.xml file which contains the information.

도움이 되었습니까?

해결책

Yes, you can do it through ListTemplateID on the event receiver and use the number you specified in the Type attribute in your list template declaration.

So for instance if your list template looks like:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="My Custom List Template"
        Type="1234"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="360"
        DisplayName="My Custom List Template"
        Description="A template for lists of type My Custom Type."/>
</Elements>

Then in your event receiver, use:

<Receivers ListTemplateId="1234">
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top