Sunday, August 25, 2013

Can't get SPContext inside Event Receiver

Just recently came to know about this, thought I might share my learning. It is basically by design that you cannot get the SPContext inside the event handlers. This might leave you wondering then how should you proceed? 

Well, you can of course use event properties passed as argument to the handler to get reference to current web, site, or the list item, etc.

Example below:

public override void FeatureActivated(SPFeatureReceiverProperties properties)

SPWeb web = properties.Feature.Parent as SPWeb;
//Some code with web 

No comments:


Related Posts with Thumbnails