Saturday, June 6, 2015

Creating a first Visual Webpart for Sharepoint 2013

As compare to earlier version of SharePoint, development on sharepoint 2013 is charm. You just need to build your development environment and you are ready for development.

I used Visual Studio Ultimate Edition for this using C#. You need to install Visual Studio on a machine where SharePoint 2013 is installed so that you can start development. The resources available on Microsoft site are more then enough to kick start with the development.

Following are steps for creating a Hello World web part.

1. Open Visual Studio (as an administrator, other wise it will restart on step 4 ;) )
2. Click File -> New -> Project as shown below

3. Select Template under Visual C#-> Office/SharePoint -> SharePoint Solution

4. On the right pane select SharePoint 2013 - Visual Web Part
5. It will ask for share point site (If you need to create SharePoint site collection follow my post)
6. Validate site URL and select "Deploy as a farm solution"

7. As soon as you click finish it will create a project and coding fun starts
8. Select usercontrol (.ascx) file in solution explorer, right click and open in design view.
9. In my example I just add som static text an a button with a message.
10. After you are done just click on start button like any other web application and Visual Studio will deploy and open your webpart in debug mode.
11. Click Edit on home page to add your webpart on home page
12. From ribbon select Insert->WebPart
13. From categories on left select custom
14. Select your first webpart from "Parts"
15. click Add

 16 Your web part is added and you can interact with it. And nice thing is that you can use VS 2013 debugging capabilities to test and debug.

No comments:

Post a Comment