SharePoint Add Ins Tutorial

Step 1: Introduction to SharePoint Add-Ins

SharePoint is a powerful platform for collaboration and document management. One of the ways you can enhance its functionality is by creating custom add-ins. In this tutorial, we will show you how to create your own SharePoint add-in from scratch.

Step 2: Setting Up Your Development Environment

Before you start creating your SharePoint add-in, you need to set up your development environment. Here are the steps:

  • Install Visual Studio 2017 or later version.
  • Install the SharePoint 2013 SDK (or newer) for Visual Studio.
  • Create a new project in Visual Studio by selecting “SharePoint 2013 Project” under the “Web” category.
  • Name your project and choose the “Empty SharePoint Project” template.

Step 3: Creating Your Add-In

Now that you have set up your development environment, it’s time to create your add-in. Here are the steps:

  • In the Solution Explorer, right-click on the project and select “Add” > “New Item”.
  • Choose “SharePoint Add-In” under the “SharePoint” category.
  • Name your add-in (for example, “MyAddIn”).
  • Set the deployment location to a site you have access to.

Step 4: Writing Your Code

Now it’s time to write some code! In this step, we will create a simple SharePoint add-in that displays a message on a page. Here are the steps:

  • Open the “MyAddIn” project and double-click on the “Feature1.cs” file.
  • Replace the existing code with the following:
using Microsoft.SharePoint;
using System.Web.UI;

namespace MyAddIn
{
    public class Feature : SharePointFeature
    {
        public override void FeatureActivated(SPWeb web)
        {
            // Create a new page layout
            SPWebTemplate template = web.AvailableWebTemplates["MyPageLayout"];
            SPPageLayout pageLayout = template.CreateNewPageLayout("MyPage");

            // Add some content to the page
            SPWebPartZone zone = pageLayout.WebPartZones[0];
            SPWebPart myWebPart = new MyWebPart();
            zone.AddWebPart(myWebPart);

            // Save the changes
            pageLayout.Update();

            // Deploy the add-in
            this.FeatureActivated(web);
        }
    }

    public class MyWebPart : WebPart
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write("<p>This is my SharePoint add-in!</p>");
        }
    }
}

Step 5: Deploying Your Add-In

Now that you have written your code, it’s time to deploy your add-in. Here are the steps:

  • Right-click on the project in the Solution Explorer and select “Deploy”.
  • Choose the site where you want to deploy your add-in.
  • Wait for the deployment process to complete.

Step 6: Testing Your Add-In

The final step is to test your add-in! Here’s how:

  • Go to the SharePoint site where you deployed your add-in.
  • Navigate to the page where you added the web part.
  • You should see a message that says “This is my SharePoint add-in!”.

Congratulations, you have successfully created and deployed a SharePoint add-in!

Note: This tutorial is just an example of how to create a basic SharePoint add-in. In real-world scenarios, you will likely need to handle errors, validate user input, and perform other tasks depending on the requirements of your add-in.