How To Add Custom Webpart In SharePoint 2013

Adding custom web parts to SharePoint 2013 allows for greater customization and functionality within your site. With Visual Studio and SharePoint Solutions, you can easily create and deploy your own custom web parts in just a few steps.

To begin, open Visual Studio and create a new project. Choose the “SharePoint Solutions” template and select the “SharePoint 2013 – Empty Project” option. Next, specify the Site URL in the SharePoint Customization Wizard and select the “Deploy as farm solution” option.

Once your project is set up, right-click on the project and select “Add -> New Item” to add a new visual web part to your project. In the .ascx file, you can define the controls for your web part, such as a textbox, button, or label.

After designing the UI, you can write the code-behind for the button click event to perform specific actions. For example, you can display a message in the label when the button is clicked.

When your web part is ready, build the solution and deploy it to your SharePoint site. Right-click on the Solution Explorer and select “Deploy” to ensure your custom web part is successfully deployed.

Now, open your SharePoint site and navigate to the page where you want to add the custom web part. Edit the page and add the web part from the “Custom” category. You can then test your web part by clicking on the button and verifying that the message is displayed in the label.

In addition to the basic functionality, you can also add custom properties to your visual web part. Define properties in the web part file and access them in the code-behind to further enhance the customization options.

It’s important to note that deploying SharePoint solutions built using Visual Studio may require admin privileges and proper database permissions. Ensure that the SQL server is running and you have the necessary rights for successful deployment.

Step-by-Step Guide for Adding a Custom Webpart in SharePoint 2013

Follow these steps to seamlessly integrate your custom web part into SharePoint 2013 and enhance the functionality of your site.

To add a custom web part in SharePoint 2013, you will need to use Visual Studio and SharePoint Solutions. Start by opening Visual Studio and creating a new project. Choose “SharePoint Solutions” under Templates and select the “SharePoint 2013 – Empty Project” template.

Next, specify the Site URL in the SharePoint Customization Wizard and choose the “Deploy as farm solution” option. This will ensure that your custom web part is deployed to the SharePoint site as a farm solution.

Once your project is set up, right-click on the project and select “Add -> New Item” to add a new visual web part. In the .ascx file, write the code to define the controls for the web part. For example, you can add a textbox, button, and label control. Then, write the code behind for the button click event to display a message in the label.

Build the solution and right-click on the Solution Explorer to deploy the solution to the SharePoint site. Open your SharePoint site and edit the page where you want to add the custom web part. Add the web part from the “Custom” category. Test the web part by clicking on the button and verifying that the message is displayed in the label.

You can also enhance your custom web part by adding custom properties. Define the properties in the web part file and access them in the code-behind. Keep in mind that deploying SharePoint solutions built using Visual Studio may require admin privileges and proper database permissions. Ensure that the SQL server is running and that you have the necessary rights.

Meet the Author

Abdul Rahim has been working in Information Technology for over two decades. Learn how Abdul got his start as a Tech Blogger , and why he decided to start this Software blog. If you want to send Abdul a quick message, then visit his contact page here.