Features in SharePoint 2010 Programmatically Using VS 2010

Features in SharePoint 2010 programmatically using VS 2010

Introduction

Today, in this article let's play around with one of the interesting and most useful concepts in SharePoint 2010.

Question: What is a feature?

In simple terms "It is a set of functionality that can be activated or deactivated at the farm, site or web level".

I think we are now good to go and implement this wonderful concept.

Step 1: Create a custom list and modify the view

Step 2: Open SharePoint 2010 Central Administration and navigate to a specific site

Step 3: Open Visual Studio 2010 and create an "Empty SharePoint Project", as in:

1.gif

Step 4: Select "Deploy as a farm solution" and click the next button. Now an empty project will be created.

2.gif

Step 5: Click on the feature and add the feature details and later also right-click on the feature to add the event receiver:

3.gif

Step 6: The complete code of EventReceiver.cs looks like this:

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
namespace FeatureApplication.Features.AzureFeature
{
}


Step 7: Deploy the solution file and add the created webpart to the SharePoint site.

Step 8: The output of the application looks like this:

4.gif

Step 9:
The output of the feature activated application looks like this:

5.gif

Step 10:
The output of the feature deactivated application looks like this:

6.gif


I hope this article is useful for you. I look forward for your comments and feedback.. Thanks Vijay Prativadi


MVC Corporation
MVC Corporation is consulting and IT services based company.