{"id":213,"date":"2013-06-16T21:59:11","date_gmt":"2013-06-17T02:59:11","guid":{"rendered":"http:\/\/www.johndhutton.com\/?p=213"},"modified":"2015-07-06T12:23:04","modified_gmt":"2015-07-06T17:23:04","slug":"creating-your-first-sharepoint-2010-visual-studio-2010-visual-web-part","status":"publish","type":"post","link":"https:\/\/www.johndhutton.com\/?p=213","title":{"rendered":"Creating your first SharePoint 2010 Visual Studio 2010 Visual Web Part"},"content":{"rendered":"<ol>\n<li>Create a new project in Visual Studio 2010 (SharePoint \u2013&gt; 2010 \u2013&gt; <strong>Visual Web Part<\/strong>), call it <em>VisualWebPartExample<\/em> and press <strong>ok<br \/>\n<\/strong><strong><a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-35-04-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-216\" alt=\"6-16-2013 9-35-04 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-35-04-PM.png\" width=\"179\" height=\"84\" \/><\/a><br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-36-47-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-217\" alt=\"6-16-2013 9-36-47 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-36-47-PM-300x207.png\" width=\"300\" height=\"207\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-36-47-PM-300x207.png 300w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-36-47-PM.png 955w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/strong><\/li>\n<li>The <em>SharePoint Customization Wizard<\/em> opens. Specify the desired target site (in my case called http:\/\/s22102) and select <em>Deploy as a farm solution<\/em>.Then press\u00a0<strong>finish<br \/>\n<\/strong>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.<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-37-33-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-218\" alt=\"6-16-2013 9-37-33 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-37-33-PM-300x214.png\" width=\"300\" height=\"214\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-37-33-PM-300x214.png 300w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-37-33-PM.png 709w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Expand VisualWebPart1<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-39-31-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-219\" alt=\"6-16-2013 9-39-31 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-39-31-PM-300x256.png\" width=\"300\" height=\"256\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-39-31-PM-300x256.png 300w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-39-31-PM.png 307w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Double click <em>VisualWebPartExample<\/em>Control.ascx<\/li>\n<li>Add a Label from control box, it should be called Label1<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-40-54-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-220\" alt=\"6-16-2013 9-40-54 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-40-54-PM-246x300.png\" width=\"246\" height=\"300\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-40-54-PM-246x300.png 246w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-40-54-PM.png 293w\" sizes=\"auto, (max-width: 246px) 100vw, 246px\" \/><\/a><\/li>\n<li>Put html &lt;br \/&gt; after to put button on next line<\/li>\n<li>Change the text of Label1 to &#8220;Hello WebPart&#8221;<\/li>\n<li>Add a button from control box, it should be called Button1<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-42-40-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-221\" alt=\"6-16-2013 9-42-40 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-42-40-PM-300x19.png\" width=\"300\" height=\"19\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-42-40-PM-300x19.png 300w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-42-40-PM.png 572w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Double click Button1, it should create a Button1_click method<\/li>\n<li>Inside the Button1_Click menthod type<br \/>\n<code>Label1.Text = <\/code><code>\"Event triggered\"<\/code><code>;<br \/>\n<\/code><\/li>\n<li>Double click Elements.xml<\/li>\n<li>Change property name Group value to\u00a0&#8220;Training&#8221;<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-36-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-223\" alt=\"6-16-2013 9-43-36 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-36-PM-300x67.png\" width=\"300\" height=\"67\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-36-PM-300x67.png 300w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-36-PM.png 607w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Right click on project and select build<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-57-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-224\" alt=\"6-16-2013 9-43-57 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-57-PM-180x300.png\" width=\"180\" height=\"300\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-57-PM-180x300.png 180w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-43-57-PM.png 328w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/li>\n<li>Right click on project and select deploy<br \/>\n<a href=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-44-07-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-225\" alt=\"6-16-2013 9-44-07 PM\" src=\"\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-44-07-PM-180x300.png\" width=\"180\" height=\"300\" srcset=\"https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-44-07-PM-180x300.png 180w, https:\/\/www.johndhutton.com\/wp-content\/uploads\/2013\/06\/6-16-2013-9-44-07-PM.png 328w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Create a new project in Visual Studio 2010 (SharePoint \u2013&gt; 2010 \u2013&gt; Visual Web Part), call it VisualWebPartExample and press ok 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\u00a0finish Visual Studio creates for you a &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-sharepoint"],"_links":{"self":[{"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=213"}],"version-history":[{"count":5,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":228,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions\/228"}],"wp:attachment":[{"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndhutton.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}