Sunday, February 3, 2008

Automatically activate a Site/Web Scoped Feature

I'm wondering if there is a way to automatically activate Site or Web scoped features after the feature installation. I did some research and found a XML attibute "ActivateOnDefault", which you can place in the feature definition file (feature.xml).

I placed the attribute into the feature.xml to force the feature to activate himself after installing, with no results...

The ActivateOnDefault attribute does not apply to site collection (Site) or Web site (Web) scoped Features.

In general, Farm-scoped Features become activated during installation, and when a new Web application is created, all installed Web application-scoped Features in it become activated.

So I think the only way to accomplish this is to write some code within the "FeatureInstalled" method of the FeatureEventHandler: Activate features through code.

No comments: