Scenario :Acvtivating a feature programmatically in the subsite.Feature is activated at site collection with scope as (Web) level .
Implementation
: Find all the activated feature at site collection level with scope as web..match the feature id of the feature to be activated and add its id in the feature collection of the site
Sample Code:
string nameFeature = string.Empty;
foreach (SPFeature featureName in web.Features)
{
Guid guid = new Guid("F1EB325C-D3E9-4a2e-9B13-626AF5A1F601");
if (featureName.Definition.Id == guid)
{
subSite.AllowUnsafeUpdates = true;
subSite.Features.Add(featureName.Definition.Id);
subSite.AllowUnsafeUpdates = false;
break;
}
}
This way we can add this feature in the web.
Enjoy!!!
No comments:
Post a Comment