Sandbox Visual Webpart: Visual Web Part are not Sandbox Solution by default
Quite recently I was with a task to develop a sandbox Webpart for the Office365 SharePoint site.

To solve error I downloaded Visual Studio 2010 SharePoint Power Tools from the following site:
In principle, visual web-parts are not supported in the sandbox environment because of the fact that we have user control i.e. .ASCX within the webpart control. The file is deployed to the _controltemplates virtual directory in the physical file system on each Web front-end server where as in a sandbox environment niether such access is granted nor it is possible to deploy physical files to the SharePoint root. Therefore here comes sandbox Visual webpart into play that makes our lives bit easier.
So I started of with a sandbox SharePoint2010 empty solution and then added a Visual WebPart. After coding some logic I attempted to deploy the that by selecting deploy option and I encountered the following error.
To solve error I downloaded Visual Studio 2010 SharePoint Power Tools from the following site:
The Correct Way:
- Create an Empty Solution of SharePoint 2010.
- Right click on the project under the solution and add new item.
- Select Sanbox Visual Webpart.
- Add some controls as per you requirement.
- After being done with the coding and successful building, right click on the project and select Package.
- This will create a .wsp file in \bin\debug\ folder.
- Now we need to upload this solution our Office365 site.
- Navigate to the site.
- Move to the site settings.
- Under Gallery, select Solutions
- In the ribbon select Upload Solutions option.
- Browse to the .wsp file press upload.
- Then on the same screen select Activate option.
- Now navigate to the desired page and in the more webpart option in ribbon you will find you webpart
Reason Behind the Error
By installing above mentioned tool, I also got an option of Visual Sandbox solution in the Visual Studio 2010 installed templates. By using this template I was able to deploy my WebPart on my site directly and then later by generating the .wsp solution I uploaded the solution to Office365.In principle, visual web-parts are not supported in the sandbox environment because of the fact that we have user control i.e. .ASCX within the webpart control. The file is deployed to the _controltemplates virtual directory in the physical file system on each Web front-end server where as in a sandbox environment niether such access is granted nor it is possible to deploy physical files to the SharePoint root. Therefore here comes sandbox Visual webpart into play that makes our lives bit easier.
Can you please guide me how to use visual webparts(sandbox)...
ReplyDeletemy requirement is need to add the list data with custom properties and with accordion and slider etc....
thank you very much
Hey ud,
ReplyDeleteI'm sorry for the belated reply. I did not see you comment in the first place.
Anyways to my understanding you can get these control via jquery. I recently worked with jq for the getting the calender control and it worked quite fine. Let me know if you still have this problem.
Cheers