The Sharepoint 2010 Blog
Coding in the Sandbox
In my Last post we had some introduction to Sandbox solutions in SharePoint 2010.
- Open Visual Studio 2010 and create an empty project, under the SharePoint Node.

-
You will now be prompted to define the solution.The Web site which you want to use for debugging, and the type of solution farm or sandboxed.

Now, from the solution explorer, add a new webpart to your feature, which you must scope to site.

Put some code in the web part, like a label.
protected
override
void CreateChildControls()
{
Label message = new
Label();
Controls.Add(message); Controls.Add(new
WebControl(HtmlTextWriterTag.Br));
message.Text = String.Format("This site contains {0} lists", SPContext.Current.Web.Lists.Count);
}
Build the Code, and hit the debug button. The code will be automatically deployed.
Now add the web part to your page.
And you will see it in action!
