I am new SharePoint programming.
I have created event receiver on item adding for the document library that allows only .doc
files to be uploaded, otherwise it gives error.
My code for event receiver is:
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
if (!properties.AfterUrl.EndsWith("doc"))
{
properties.Cancel = true;
properties.ErrorMessage = "Only .doc files are accepted";
}
}
Now I want to make it active only the time the feature is active, when the feature is deactivated the event receiver should also be disabled. I think it may be possible with FeatureDeactivating() method.
How to implement it? Please help.