Below you will find pages that utilize the taxonomy term “EventReceiver”
Posts
ListUrl on EventReceiver
When you create an eventreceiver, you get the ListTemplateId attribute. It works fine. But if you want the eventreceiver to trigger on one particular list, just replace ListTemplateId attribute with ListUrl. For Pages you can use:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Receivers **ListUrl="$Resources:cmscore,List\_Pages\_UrlName;"**\> <Receiver> <Name>NewsPageEventReceiverItemUpdated</Name> <Type>ItemUpdated</Type> <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly> <Class>Contoso.EventReceivers.NewsPageEventReceiver.NewsPageEventReceiver</Class> <SequenceNumber>1000</SequenceNumber> </Receiver> </Receivers> </Elements>
Posts
AfterProperties kräver InternalName
AfterProperties kommer inte leda till Exception, men de kommer returnera bara null, om du använder DisplayName. Man måste ha InternalName. Här är ett litet exempel på hur man kan få ut värden före och efter uppdateringen. Exemplet har testats i ItemUpdated-eventreceiver.
var before = properties.BeforeProperties; var after = properties.AfterProperties; var contentDisplayName = "News Content"; var list = properties.List; var contentInternalName = list.Fields\[contentDisplayName\].InternalName; var contentBefore = before\[contentInternalName\]; var contentAfter = after\[contentInternalName\];