Skip to content

Visual Studio 2012 – Visual web part in Sandboxed Solution

February 23, 2012

Visual Studio 2010 did not support adding Visual Web Parts to Sandboxed solutions. This inconvenience was fixed in Visual Studio 20120and works seamlessly in the developer preview version.

Here are the steps to create a visual web part in sandbox:

Create a new SharePoint 2010 project:

When VS ask, chose Sandboxed solution and not farm solution,

Add a new visual Web part to the project:

Make some changes to the web part, such as add a label with the text Hello World.

Build and deploy the solution. After the deployment completed, open the SharePoint site in the browser and add the web part to one of the pages.

And it works fine:

One more thing about sandboxed solutions:
In Visual Studio 11 Intellisense only displays the APIs that are compatible with the sandboxed solution. If you still try using unsupported APIs, you will get a compiler error:

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: