Monday, July 8, 2013

Sharepoint programatically activate feature if it is not active and instaled


Here is a small code sample which will activate featrue using C#

In this sample we i am checking feature is activated or not and installed or not before trying to activate


// This is to check if feature is installed or not
if (SPFarm.Local.FeatureDefinitions[new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb")] != null)
{

//This is to check feature is activated or not
  if (web.Features[new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb")] != null)
  web.Features.Remove(new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb"));
                
}





Thank you !!!


1 comment:

  1. Hi Srikanth,

    Nice Sharepoint Blog,all of your posts are really very useful,thanks for sharing them.





    Sharepoint Development

    ReplyDelete