How to use Visual webpart in SharePoint 2010 in Sandbox Solution - sharepoint

I am trying to use a Visual Webpart in a sandbox solution. However every I deploy it: it gives me the following error:
Error 1 The deployment type "TemplateFile" of file "VisualWebPart1UserControl.ascx" in Project Item "VisualWebPart1" is not compatible with a Feature in a Sandboxed Solution.
I did some research and found out that Visual WP is not supported in Sandbox solutions. Is there anyway I can have Visual WP in a sandbox solution?
And is there any specific reason as to why Visual WP is not really supported in Sandbox solution.

Use VS Sharepoint Power Tools. It has Visual Web Part item template for sandbox solutions.
http://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9/

Please follow this link
Restrictions on Sand boxed Solutions in SharePoint 2010
http://msdn.microsoft.com/en-us/library/gg615454.aspx)
it will provide you the detaisl about the limitation of Sandboxed solution.
RoManiac is correct, you can not deploy visual web part in Sanboxed solution as it contains user control.
Mark as answer if it helps you.

You can deploy a solution directly onto your SharePoint Server farm, or you can deploy the solution into a sandbox. A sandbox is a restricted execution environment that enables programs to access only certain resources, and that keeps problems that occur in the sandbox from affecting the rest of the server environment. Solutions that you deploy into a sandbox, which are known as sandboxed solutions, cannot use certain computer and network resources, and cannot access content outside the site collection they are deployed in.
Normally, a Visual Web Part cannot be sandboxed, as it needs to work outside the sandbox in order to load the underlying user control for the Visual Web Part.
This is how to have a Visual WP in a sandbox solution:
http://msdn.microsoft.com/en-us/office365trainingcourse_lab_2_1_topic3.aspx

Related

Convert asp.net website solution to visual web part

I have a small website written in asp.net c#. It consists of 7 pages or less, connected to a database and references a class library. How to convert it to a visual web part in sharepoint 2013? my colleague advised me of copying the codes from the website solution to a visual web part solution. The question is, is his suggestion feasible? are there any other ways of doing it besides iframes and my colleague's suggestion?
Your options depends on if your solution will live in a Publishing Portal or not. The most generic way would probably be to use a visual webpart and host it there. If you would like a more comparable version of this from your current solution you can build and deploy custom page layouts hosting your code.

Provisioning Sites, Lists, Libraries etc within SharePoint

Previously when provisioning list, libraries, site columns, content types, list definitions etc in SharePoint I typically used SharePoint features, deployed via a WSP - or used PowerShell scripts. This meant I had a package that could be deployed to DEV / TEST / PROD.
I'm working with SharePoint within Office 365 and unsure on the best way to provision lists / libraries / features within SharePoint.
Options:
No Code Sandboxed Solutions
Trying to avoid using these as the information from Microsoft on whether they are deprecated is flaky - however sandboxed solutions would allow me to deploy features with list definitions etc. I know sandboxed solutions with c# are definitely deprecated, but the info around no code solutions is poor.
Apps
I know apps can provision at both the app and host web level, but creating lists, libraries etc using the CSOM seems like a lot of effort and a step backwards.
PowerShell
The SP Online PowerShell is nowhere near as powerful as on-prem SP. I can provision site collections through this, but not lists or libraries...
I'm keen to know how other developers are deploying to Office 365, specifically around provisioning sites with specific list definitions, libraries, content types and so on...
Thanks
Microsoft did clarify the position on No Code Sandbox solutions - http://blogs.msdn.com/b/sharepointdev/archive/2014/01/14/deprecation-of-custom-code-in-sandboxed-solutions.aspx
Also if you are looking at using Powershell to deploy then you might want to go down the route of using CSOM from within PowerShell - SharePoint Client Browser for SharePoint 2013 is good for setting up a session also very good for viewing the content of a 365 tenant - http://spcb.codeplex.com/
I have been using code based provision for almost two years without any issues at all.
Server side model works just fine, CSOM has some limitation but stil cool one and JSOM could deliver the same feature set as both CSOM and SSOM, sorta 95% :)
PowerShell is not the best option as it hard to integrate into CI, put some unit testing and regressions.
As you mentioned, this is "step back", but if only you don't have any framework or foundation for that. My libraries are internal one, but there is SPGenesis at codeplex and SPMeta2.
As community don't really care, need or with such libraries for provisioning (yep, let's face it), there are much such libraries at all, but there are lots of "MVP" samples sorta "hello world" level.
Finally, what I would suggest is to invest your time and effort in code based provision.
This is a future, that's it ;)
UPD
Struggling with SharePoint's API inconsistency, bugs, "by-design" behaviour, unaffordable amount of time to write, support and upgrade WSP packages and XML, a team of passionate SharePoint professionals decided to come up with robust, testable and repeatable way to deploy such artifacts like fields, content types, libraries, pages and many more.
Enjoy and let us know how it goes.
SPMeta2 at GitHub
SPMeta2 at Nuget
SPMeta2 Documentation Wiki
SPMeta2 Bugtracker

Does SharePoint Online (Office 365 Cloud) support inline code blocks? SharePoint Designer code view?

Will we be able to add .NET code blocks to a page in SharePoint 365 - the cloud version of SharePoint? If so, how do we allow code blocks in the web.config?
Will we be able to use SharePoint designer to customize forms and create dataviews with external datasources?
Can we have asp.net codebehind files and class references? (I suspect not)
.NET code blocks (server-side scripts) are not supported in Office 365. You should build your ASPX page purely from controls and web parts, which would contain the code. Solutions for the SharePoint Online share their restrictions with sandboxed solutions for SharePoint 2010. The solution scope is a site collection; not a web application and thus you cannot access the web.config. However, you may not need to; you're bound only to a single site collection and the most usual task - adding SafeControls - is supported, although the SharePoint engine does not use web.config to maintain them. You can see an example of deploying a web part.
You can use the Designer to customize pages, forms and views. External data sources (entity types) - BCS - were added to SharePoint Online by the end of the last year. I haven't checked what connector types are supported; I presume SQL and WS sources, at least.
You cannot have the code-behind in ASPX pages. There is no ASP.NET compilation of pages and user controls available; that's why you have to compose your pages of coded controls and web parts only. However, there is a trick to circumvent this - the Visual Web Part. The original visual web part could not be used in a sandboxed solution because it relied on the ASP.NET compilation. There is a template available in Visual Studio 2010 SharePoint Power Tools that packages pre-compiled code to the solution and is friendly to the sandbox.
You can develop and test your sandboxed solutions on your local SharePoint 2010 prior deploying them to the SharePoint Online. Although I was surprised that deployng a solution to the SharePoint Online was kind of faster than to my local farm :-) MSVS makes the development really comfortable.
--- Ferda
Not being a .NET developer, here is my limited knowledge. Office 365 is a multi-tenant implementation of SharePoint and you you should have the following capabilities:
upload code blocks as sandboxed solutions
ability to customize forms and data views with SharePoint Designer
Note that Office 365 offers 30 day trials that would allow you to test drive it. Let me know if you need more details as there are a couple caveats to be aware of when you start a trial.
This question relates to how to implement what Mr Prantl suggested.
Where to write C# code for office365 sharepoint site
Hope this helps.

How to test sharepoint web parts and other sharepoint development locally?

I have been investigating building web parts for sharepoint 2010 and currently have a single instance of SP2010 on the work servers. I would very much like to be able to test them locally (on my laptop) if possible, without having to install sharepoint 2010 on my laptop (is this even possible?!)
Is there a way to test web parts and do I need to install all/part of sharepoint on my laptop?
Thanks
If your Web part is simply displayed in a SharePoint page, without using the SP API, you could simply host it in an ASP.NET page on your laptop, but this is not a common scenario.
One new feature of SP 2010 is the client API, i.e. a subset of the full API that can be used outside of the farm. If your usage of the API fits in this subset, this could be useful, but you will still need to access a SP server somewhere.
Another option is to put all the code that uses the SP API in something similar to a Database Access Layer which talks to SP on one hand and returns business objects (not lists or lists items). This way, you could simulate this part on your laptop and concentrate on the look of the Web part and its business rules, without SP. If this part is in its own DLL, the only reference to SP DLLs would be there, so the project on your laptop would not need to reference the SP DLLs.
There are two ways: the good one and old-school.
The good way is to install Sharepoint Services (http://technet.microsoft.com/en-us/windowsserver/sharepoint/default.aspx) and deploy WP locally. It works only if you have Windows Vista or Seven. It is the most productive way so i recomend it.
Another way comes from SP2003 era... The idea is to develop custom Web Control, test it locally with IIS or just development server, and then to embed it into web part. The method is described here - http://www.reflectionit.nl/SmartPart.aspx . It's an old and painful method. Unfortunately we can't use (without troubles) Microsoft.Sharepoint.dll etc
P.S. Sorry for my English...
This came up at our office and we ended up installing Sharepoint Foundation on each developer's PC, which allows us to develop and debug locally. Here is the link that I used to get this working.
Setup Dev Env. For Sharepoint Foundation on Win 7
I would say get a virtual machine.. but I dont think you can run 64bit VM's on a 32bit OS.
You'll have to upgrade to 64bit.
I don't think there is a good way around this; you will spend a lot of time on something of questionable value if you do not install SharePoint either on your laptop or in a VM and do it the proper way.
You can just swap out the inheritance from the SharePoint Web Part to the ASP.NET equivalent and back again - all the functionality is the same because the newer version was designed with backwards compatibility in mind. Use the ASP.NET version when testing on your laptop.
Here is some more info :-)
http://weblogs.asp.net/scottgu/archive/2006/09/02/Writing-Custom-Web-Parts-for-SharePoint-2007.aspx

How do I get started developing a simple workflow application in SharePoint?

I would like to start developing a simple Workflow application in Sharepoint. What files should I download?
SharePoint Server 2007 SDK?
SharePoint Server?
SQL Server?
Visual Studio?
other?
Are they all required for workflow development?
I do not have SharePoint anywhere, please include its components in your answer.
If you don't have SharePoint installed, the free WSS 3.0 version is available for download from Microsoft. Follow these steps to install in a single server environment. It will install a basic version of SQL Server. Note this is suitable for prototyping only, not a production deployment, due to restrictions in the basic install.
Then use SharePoint Designer to create the workflows, free from Microsoft. There is no need for any other software. This allows you to configure workflow against a particular list in your SharePoint site with a wizard-like interface. See this topic on Office Online for more information.
If you need to develop a reusable workflow that can be deployed to many different sites or a production SharePoint instance then this is a much larger time investment. Start by reading one of the many other questions on this site for "getting started with SharePoint" that will give resources to how the product works. Be warned: there's a reasonable learning curve. Once you have a solid understanding, you could follow it up with a book such as Professional SharePoint 2007 Workflow Programming (first search result).
Another "warning" on designer...
The workflows you create there are allways fixed to a single list, and you cannot deploy them to a production server. So the "reusable" part from the above answer even includes a "portable" component.
Also those workflows are very static, since they only contain some speciffic actions that you can perform. (So no custom code etc).

Resources