Hi All,
Assuming that we have installed a feature but based on our requirement, we require to activate the feature, then we can accomplish this dynamically by code.
Here is the way we can accomplish this task.
Lets assume that spCurrentWeb is a web on which you want to activate the feature. you must be knowing features GUID.
spCurrentWeb.Features will return you all features installed at that site level and the you just add it to the feature collection to activate it.
spCurrentWeb.AllowUnsafeUpdates = true;
SPFeatureCollection featureCollect = spCurrentWeb.Features;
featureCollect.Add({"feature GUID"}, true);
spCurrentWeb.Update();
spCurrentWeb.AllowUnsafeUpdates = false;
That's it. you job is done. As soon as this feature is added to feature collection it will automatically activate if user has sufficient rights for it.
SharePoint Kings,Technosavvy guys hunting SharePoint Challenges... SharePoint 2013, SharePoint 2010, MOSS 2007, Windows Workflow Foundation, Project Server and Other Related Technologies.
Subscribe to:
Post Comments (Atom)
Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!
If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com
No comments:
Post a Comment