June 16

Creating your first SharePoint 2010 Visual Studio 2010 Visual Web Part

  1. Create a new project in Visual Studio 2010 (SharePoint –> 2010 –> Visual Web Part), call it VisualWebPartExample and press ok
    6-16-2013 9-35-04 PM
    6-16-2013 9-36-47 PM
  2. The SharePoint Customization Wizard opens. Specify the desired target site (in my case called http://s22102) and select Deploy as a farm solution.Then press finish
    Visual Studio creates for you a project customized for the SharePoint development. It adds automatically packaging and feature settings and an example Visual Web Part.
    6-16-2013 9-37-33 PM
  3. Expand VisualWebPart1
    6-16-2013 9-39-31 PM
  4. Double click VisualWebPartExampleControl.ascx
  5. Add a Label from control box, it should be called Label1
    6-16-2013 9-40-54 PM
  6. Put html <br /> after to put button on next line
  7. Change the text of Label1 to “Hello WebPart”
  8. Add a button from control box, it should be called Button1
    6-16-2013 9-42-40 PM
  9. Double click Button1, it should create a Button1_click method
  10. Inside the Button1_Click menthod type
    Label1.Text = "Event triggered";
  11. Double click Elements.xml
  12. Change property name Group value to “Training”
    6-16-2013 9-43-36 PM
  13. Right click on project and select build
    6-16-2013 9-43-57 PM
  14. Right click on project and select deploy
    6-16-2013 9-44-07 PM