2

While I was creating a visual web part in Visual Studio 2010, I also saw an option to create Visual Web Part (Sandboxed) under Visual Studio Template Gallery.

I need to know how does a Sandboxed Visual Web Part differs from the non-Sandboxed version.

Hope I'm clear with my question.

Thanks.

2 Answers 2

4

The original (Farm Solution) Visual Web Part uses a User Control for the UI. The User Control gets deployed up into the SharePoint System Folders and the Web Part just dynamically loads the User Control into the page at run time.

In a Sandbox Solution we can't deploy files into the SharePoint System Folders so we can't use the same technique. To address this the Visual Studio team came up with an interesting workaround. The Sandbox Visual Web Part simulates having a User Control. Your project contains an ASCX file that is only used at design time. When you save the ASCX file, Visual Studio parses it and turns all the markup into C# or VB code. So when you deploy the Web Part is just code which can be deployed as part of a Sandbox Solution (for the time being).

It is important to note that Sandbox Solutions that contain managed code (C# or VB) are considered deprecated and, at some point in the future, will no longer be supported in SharePoint.

I cover the differences between the two templates in detail in this video: Using the Visual Web Part Template in Visual Studio 2012.

1

At Sandbox You can't Use some of function, which could be very harmful to Your serwer. In Sandbox you write a code when you dont write a producting code. Only when You want a practice. Inteli sense is much protecting your code to don't destroy your server, but You can't do a lot of function, which sometimes could be very harmful. If You practice it's beter to Use a sandboxed, but if You write the code to producting server You Should Use a Farm Solution. You Can read a lot here about the Sandbox Solution: http://technet.microsoft.com/en-us/library/ee721992%28v=office.14%29.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.