<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Corey Roth [MVP] : SharePoint 2010, WebPart, SharePoint Online</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/WebPart/SharePoint+Online/default.aspx</link><description>Tags: SharePoint 2010, WebPart, SharePoint Online</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>A look at Visual Web Parts in Visual Studio 11</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/01/12/a-look-at-visual-web-parts-in-visual-studio-11.aspx</link><pubDate>Thu, 12 Jan 2012 16:23:15 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:5453</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=5453</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/01/12/a-look-at-visual-web-parts-in-visual-studio-11.aspx#comments</comments><description>&lt;p&gt;I recently published my first post about SharePoint development with Visual Studio 11 and I mentioned that there were some changes in how the Visual Web Part worked.&amp;#160; If you are familiar with the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/introducing-the-visual-web-part-in-sharepoint-2010.aspx"&gt;Visual Web Part in Visual Studio 2010&lt;/a&gt;, you know it really is just a glorified user control and it doesn’t work in the sandbox.&amp;#160; Luckily, the community stepped up and provided some alternatives that do work.&amp;#160; Visual Studio 11 now provides a Visual Web Part that works in the sandbox out of the box.&amp;#160; Since I am always curious about how things work, I decided to take a deeper look to see just how this web part is implemented now.&amp;#160; &lt;/p&gt;  &lt;p&gt;Let’s first take a look at the files that we get when we add a Visual Web Part to the project.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS11DPVisualWebPartSolutionExplorer_341901DF.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="VS11DPVisualWebPartSolutionExplorer" border="0" alt="VS11DPVisualWebPartSolutionExplorer" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS11DPVisualWebPartSolutionExplorer_thumb_59A27F40.png" width="244" height="105" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;There are actually a few less files that we had in Visual Studio 2010.&amp;#160; We’ll see why here shortly.&amp;#160; What we get are the following&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Elements.xml – Used to deploy the .webpart file via module element&lt;/li&gt;    &lt;li&gt;A .ascx file – The actual user control with the design surface&lt;/li&gt;    &lt;li&gt;A .ascx.cs file – The code behind for the user control&lt;/li&gt;    &lt;li&gt;A .ascx.g.cs file – This file is generated by the designer.&amp;#160; We’ll talk about it more&lt;/li&gt;    &lt;li&gt;A .webpart file – The file that goes into the Web Part gallery that has the assembly path to the web part&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If we look at the .ascx.cs file, we’ll see our first difference.&amp;#160; &lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; SharePointProject1.HelloWorldWebPart&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:#2b91af;"&gt;ToolboxItemAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;false&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;partial&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HelloWorldWebPart&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;WebPart&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OnInit(&lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;base&lt;/span&gt;.OnInit(e);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeControl();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;You’ll notice that this file inherits from &lt;em&gt;WebPart&lt;/em&gt; now instead of &lt;em&gt;UserControl&lt;/em&gt;.&amp;#160; At this point, you might be wonder how does all of this work.&amp;#160; Well, the magic is in the designer and what ends up in the .ascx.g.cs file.&amp;#160; Let’s take a look at it when it’s first created.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//------------------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// &amp;lt;auto-generated&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; This code was generated by a tool.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; Runtime Version:2.0.50727.5448&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; Changes to this file may cause incorrect behavior and will be lost if&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; the code is regenerated.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// &amp;lt;/auto-generated&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//------------------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; SharePointProject1.HelloWorldWebPart {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebPartPages;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.Security;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint.Utilities;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Collections.Specialized;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Collections;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.Profile;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Text;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.Caching;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Configuration;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.SessionState;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.HtmlControls;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;partial&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HelloWorldWebPart&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;implicit&lt;/span&gt; &lt;span style="color:blue;"&gt;operator&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.&lt;span style="color:#2b91af;"&gt;TemplateControl&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;HelloWorldWebPart&lt;/span&gt; target) &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; target == &lt;span style="color:blue;"&gt;null&lt;/span&gt; ? &lt;span style="color:blue;"&gt;null&lt;/span&gt; : target.TemplateControl;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; @__BuildControlTree(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::SharePointProject1.HelloWorldWebPart.&lt;span style="color:#2b91af;"&gt;HelloWorldWebPart&lt;/span&gt; @__ctrl) {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; InitializeControl() {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;this&lt;/span&gt;.@__BuildControlTree(&lt;span style="color:blue;"&gt;this&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;this&lt;/span&gt;.Load += &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.&lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page_Load);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;virtual&lt;/span&gt; &lt;span style="color:blue;"&gt;object&lt;/span&gt; Eval(&lt;span style="color:blue;"&gt;string&lt;/span&gt; expression) {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.&lt;span style="color:#2b91af;"&gt;DataBinder&lt;/span&gt;.Eval(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page.GetDataItem(), expression);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;virtual&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; Eval(&lt;span style="color:blue;"&gt;string&lt;/span&gt; expression, &lt;span style="color:blue;"&gt;string&lt;/span&gt; format) {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.&lt;span style="color:#2b91af;"&gt;DataBinder&lt;/span&gt;.Eval(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page.GetDataItem(), expression, format);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;It may not make a lot of sense at this point, but when you start adding controls, it makes more sense.&amp;#160; I added a label, textbox, and button control to the design surface.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS11DPVisualWebPartDesigner_51AADCDE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="VS11DPVisualWebPartDesigner" border="0" alt="VS11DPVisualWebPartDesigner" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/VS11DPVisualWebPartDesigner_thumb_1108906F.png" width="407" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This looks like a typical user control that you are confortable working with.&amp;#160; Now let’s take a look at what the .ascx.g.cs file has now.&amp;#160; I’ll just include the parts that changed.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;     &lt;p style="margin:0px;"&gt;[&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt; @__BuildControlLabel1() {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt;();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;this&lt;/span&gt;.Label1 = @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ApplyStyleSheetSkin(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ID = &lt;span style="color:#a31515;"&gt;&amp;quot;Label1&amp;quot;&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.Text = &lt;span style="color:#a31515;"&gt;&amp;quot;Label&amp;quot;&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;}&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;[&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;TextBox&lt;/span&gt; @__BuildControlTextBox1() {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;TextBox&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;TextBox&lt;/span&gt;();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;this&lt;/span&gt;.TextBox1 = @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ApplyStyleSheetSkin(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ID = &lt;span style="color:#a31515;"&gt;&amp;quot;TextBox1&amp;quot;&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;}&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;[&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Button&lt;/span&gt; @__BuildControlButton1() {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Button&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Button&lt;/span&gt;();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;this&lt;/span&gt;.Button1 = @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ApplyStyleSheetSkin(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Page);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.ID = &lt;span style="color:#a31515;"&gt;&amp;quot;Button1&amp;quot;&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl.Text = &lt;span style="color:#a31515;"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; @__ctrl;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;}&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;[&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.ComponentModel.&lt;span style="color:#2b91af;"&gt;EditorBrowsableState&lt;/span&gt;.Never)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; @__BuildControlTree(&lt;span style="color:blue;"&gt;global&lt;/span&gt;::SharePointProject1.HelloWorldWebPart.&lt;span style="color:#2b91af;"&gt;HelloWorldWebPart&lt;/span&gt; @__ctrl) {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; System.Web.UI.&lt;span style="color:#2b91af;"&gt;IParserAccessor&lt;/span&gt; @__parser = ((System.Web.UI.&lt;span style="color:#2b91af;"&gt;IParserAccessor&lt;/span&gt;)(@__ctrl));&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(&lt;span style="color:blue;"&gt;new&lt;/span&gt; System.Web.UI.&lt;span style="color:#2b91af;"&gt;LiteralControl&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;\r\n&amp;lt;div&amp;gt;\r\n&amp;#160;&amp;#160;&amp;#160; &amp;quot;&lt;/span&gt;));&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt; @__ctrl1;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl1 = &lt;span style="color:blue;"&gt;this&lt;/span&gt;.@__BuildControlLabel1();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(@__ctrl1);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(&lt;span style="color:blue;"&gt;new&lt;/span&gt; System.Web.UI.&lt;span style="color:#2b91af;"&gt;LiteralControl&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;\r\n&amp;#160;&amp;#160;&amp;#160; &amp;quot;&lt;/span&gt;));&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;TextBox&lt;/span&gt; @__ctrl2;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl2 = &lt;span style="color:blue;"&gt;this&lt;/span&gt;.@__BuildControlTextBox1();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(@__ctrl2);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;global&lt;/span&gt;::System.Web.UI.WebControls.&lt;span style="color:#2b91af;"&gt;Button&lt;/span&gt; @__ctrl3;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__ctrl3 = &lt;span style="color:blue;"&gt;this&lt;/span&gt;.@__BuildControlButton1();&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(@__ctrl3);&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; @__parser.AddParsedSubObject(&lt;span style="color:blue;"&gt;new&lt;/span&gt; System.Web.UI.&lt;span style="color:#2b91af;"&gt;LiteralControl&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;\r\n&amp;lt;/div&amp;gt;\r\n&amp;quot;&lt;/span&gt;));&lt;/p&gt;      &lt;p style="margin:0px;"&gt;}&lt;/p&gt;   &lt;/div&gt; &lt;/div&gt;   &lt;p&gt;The designer creates methods for each ASP.NET control you drag onto the page and then the &lt;em&gt;@__BuiltControlTree&lt;/em&gt; method calls those methods to effectively add those controls to the page.&amp;#160; The HTML div elements that I added to the page simply get included as a &lt;em&gt;LiteralControl&lt;/em&gt;.&amp;#160; Needless to say you don’t want to mess with this file.&amp;#160; I have to give props to the Visual Studio and SharePoint teams.&amp;#160; I am sure this was a lot of work to implement.&amp;#160; :)&amp;#160; Give it a try if you want.&amp;#160; It seems to work well and the best part is what I have tried so far works with SharePoint Online.&lt;/p&gt;  &lt;p&gt;If you haven’t checked out Visual Studio 11 yet, head over to the &lt;a href="http://msdn.microsoft.com/en-us/vstudio/hh127353"&gt;developer site&lt;/a&gt; where you can get the download link and find out everything that’s new.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=5453" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Sandboxed+Solution/default.aspx">Sandboxed Solution</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Online/default.aspx">SharePoint Online</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+11/default.aspx">Visual Studio 11</category></item><item><title>Office 365 How to: Build and Deploy a Web Part with SharePoint Online</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/04/01/office-365-how-to-build-and-deploy-a-web-part-with-sharepoint-online.aspx</link><pubDate>Fri, 01 Apr 2011 16:08:28 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:4521</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=4521</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/04/01/office-365-how-to-build-and-deploy-a-web-part-with-sharepoint-online.aspx#comments</comments><description>&lt;p&gt;You know by now that the cloud is hot and Microsoft says “we’re all in”.&amp;#160; That being said, there has never been a better time to push all of those chips forward and&amp;#160; jump on the bandwagon.&amp;#160; It’s time to get some experience with SharePoint Online / Office 365.&amp;#160; I know most people don’t have access to the Office 365 beta yet, but when it opens up, you should sign up for the public beta and start getting familiar with it.&amp;#160; If you haven’t seen SharePoint Online yet, check our my previous &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/03/07/a-quick-look-at-sharepoint-online-in-office-365.aspx"&gt;article&lt;/a&gt; which gives a quick tour of it.&amp;#160; I plan to write more about SharePoint Online in the future, so I figured the best place to start is with an introductory development article on building and deploying a web part.&amp;#160; My past series on building and deploying web parts to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2010&lt;/a&gt; and &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2007&lt;/a&gt; are still the most popular articles on DotNetMafia.com.&amp;#160; Let’s take what we learned there and see how we deploy web parts to the cloud.&lt;/p&gt;  &lt;p&gt;Before we get started, let’s reiterate what we’re working with.&amp;#160; With Office 365, your development scenario involves sandboxed solutions.&amp;#160; As you know, these solutions are deployed to the site collection level and offer a restricted subset of the SharePoint API.&amp;#160; If you are already confortable working with sandboxed solutions, you are in great shape to begin SharePoint Online development.&lt;/p&gt;  &lt;p&gt;What does the development environment look like?&amp;#160; Well, you know that SharePoint 2010 VM you already have?&amp;#160; You’re looking at it.&amp;#160; Just like Azure, SharePoint Online development also used the “Over the fence” development methodology.&amp;#160; Meaning, you develop your code locally and then throw it over the fence and hope it works.&amp;#160; This may sound bad, but it’s really not a big deal and the Azure people have been doing it for a while.&amp;#160; AppFabric is close to Azure, but there is always a possibility of differences when you get it in the cloud.&amp;#160; As long as you build a sandboxed solution and don’t make use of unsupported features (i.e.: PerformancePoint, BCS, etc), more than likely your code will work when it gets to the cloud.&amp;#160; There may be things that you can do in a Sandboxed solution in SharePoint 2010 compared to SharePoint Online, but it’s far too early to tell at this point.&amp;#160; To get started developing web parts in the cloud, you pretty much need a copy of SharePoint 2010 (or SharePoint Foundation) installed somewhere locally.&amp;#160; This could be native on your Windows 7 machine or inside a virtual machine.&amp;#160; Wherever it is, you will obviously need Internet access to get your code to the cloud.&lt;/p&gt;  &lt;p&gt;To get started developing in the cloud, the first step is to build the web part on your local SharePoint environment.&amp;#160; I won’t go through all the steps here, because most of them are the same from my article on &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;2010 Web Part Development&lt;/a&gt;.&amp;#160; However, I will go through the important steps.&amp;#160; The first step is to create a new Empty SharePoint 2010 Project in Visual Studio 2010.&amp;#160; Specify the URL to a local site on your SharePoint server.&amp;#160; Don’t use the address of your SharePoint Online site.&amp;#160; It won’t work.&amp;#160; When prompted for the solution type, choose Sandboxed Solution.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioSandboxedSolution_462C7AE2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOVisualStudioSandboxedSolution" border="0" alt="SPOVisualStudioSandboxedSolution" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioSandboxedSolution_thumb_7098ABFF.png" width="463" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;At this point, you have a regular SharePoint project in Visual Studio.&amp;#160; Add a web part to the project just like you would in SharePoint 2010.&amp;#160; Sticking with the Hello World type example, we put some code like the following in our web part.&lt;/p&gt; &lt;strong&gt;   &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;     &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; SharePointOnlineProject3.HelloCloudWebPart&lt;/p&gt;      &lt;p style="margin:0px;"&gt;{&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; [&lt;span style="color:#2b91af;"&gt;ToolboxItemAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;false&lt;/span&gt;)]&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HelloCloudWebPart&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;WebPart&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; CreateChildControls()&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Controls.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Label&lt;/span&gt;() { Text = &lt;span style="color:#a31515;"&gt;&amp;quot;Hello, Cloud!&amp;quot;&lt;/span&gt; });&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;      &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;      &lt;p style="margin:0px;"&gt;} &lt;/p&gt;   &lt;/div&gt; &lt;/strong&gt;  &lt;p&gt;At this point, we can test our code locally on our SharePoint server.&amp;#160; Build and deploy the project and then add your web part to a test page on your site.&amp;#160; Again, if you aren’t familiar with these steps, take a look at my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx"&gt;Building and Deploying Web Parts with SharePoint 2010&lt;/a&gt; post. If the code, works you should see a similar page like the one below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartLocal_3DC8A58B.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOHelloCloudWebPartLocal" border="0" alt="SPOHelloCloudWebPartLocal" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartLocal_thumb_04459594.png" width="517" height="318" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, we’re ready to send our web part “to the cloud!”.&amp;#160; How do we do that?&amp;#160; Start by using the Package menu to build a SharePoint package (.wsp file).&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioPackageSolution_35D10329.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOVisualStudioPackageSolution" border="0" alt="SPOVisualStudioPackageSolution" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOVisualStudioPackageSolution_thumb_6E7BAD36.png" width="412" height="205" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This creates a .wsp file located in the bin folder of the project.&amp;#160; We’ll use this file to deploy our web part to the cloud.&amp;#160; It’s now time to open up a browser and connect to your instance of SharePoint Online.&amp;#160; Once you get there, we deploy a sandboxed solution just like we would on-premises.&amp;#160; Go to Site Settings –&amp;gt; Solutions to view the Solutions Gallery.&amp;#160; Click on the &lt;em&gt;Solutions&lt;/em&gt; button in the ribbon, and then click &lt;em&gt;Upload Solution&lt;/em&gt;.&amp;#160; Browse to the bin folder of your Visual Studio project and select the file ending in .wsp.&amp;#160; Once it uploads, be sure and click the &lt;em&gt;Activate &lt;/em&gt;button.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOSolutionActivate_34F89D3F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOSolutionActivate" border="0" alt="SPOSolutionActivate" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOSolutionActivate_thumb_6279BD02.png" width="383" height="221" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, you just need to ensure the feature is activated by going to Site Settings –&amp;gt; Site Collection Features.&amp;#160; If it is not activated, click the activate button.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOFeatureActivated_2D00FADD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOFeatureActivated" border="0" alt="SPOFeatureActivated" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOFeatureActivated_thumb_4CAFD4A5.png" width="443" height="28" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Your web part has now been thrown over the fence and deployed to the cloud!&amp;#160; Test it out by going to any page on the site and adding the web part to the page.&amp;#160; You’ll find your web part in the &lt;em&gt;Custom&lt;/em&gt; section by default.&amp;#160; If all goes well, your web part should work here too.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartCloud_6C5EAE6D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SPOHelloCloudWebPartCloud" border="0" alt="SPOHelloCloudWebPartCloud" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SPOHelloCloudWebPartCloud_thumb_60C8F12E.png" width="365" height="297" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Congratulations, you have now deployed code to the cloud!&amp;#160; It’s really not that hard is it?&amp;#160; Now, you might be wondering if you can debug your solution.&amp;#160; Unfortunately, the answer is no.&amp;#160; If you have an issue, you have to step through it locally on your on-premises SharePoint server.&amp;#160; That’s all there is to getting started with SharePoint Online development.&amp;#160; As you can see it’s very familiar to sandboxed solutions development with your on-premises server.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=4521" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Online/default.aspx">SharePoint Online</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Office+365/default.aspx">Office 365</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Office+365+Grid/default.aspx">Office 365 Grid</category></item></channel></rss>