Convert asp.net website solution to visual web part - sharepoint

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.

Related

SharePoint 2013 Dynamic Data on all pages

If I have a requirement of displaying the a content on all the pages inside a header, Whats the best way to do that in an SharePoint 2013?
I am working on a master page that will be using the design manager and there is possibility of using the same master page in the SharePoint online too. The reason why I want to know what is the best way, when I use this same master page in SharePoint online I would like avoid redoing that entire coding for getting a dynamic data from the web service.
Several ways that I have been planning is below
- User control method
- Web part method, but requires server side coding which I doubt can used in online version
This is a complete dynamic data that will be retrieved by a web service and no internal SharePoint data be used.
Thanks for reading
Deepak
If its possible to consume web-service using jQuery/Ajax call you can go with that
Or else if you want to use c#, might need to go with provider hosted app feature (sharepoint 2013)
You can create a Visual Web Part for SharePoint 2013 Online.
Your web part will be contained in a Sandbox Solution which you will develop locally. Once development is complete you will upload the Solution Package created by Visual Studio to SharePoint Online.
https://sharepoint.stackexchange.com/questions/80164/create-visual-webpart-for-sharepoint-online
http://sharepoint-community.net/profiles/blogs/sharepoint-online-2013-web-part-deployment

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

Help me understand Sharepoint

We've been asked to create a web application. One part of the specification is that in future, it can be integrated into Sharepoint. The last version of this app was written in PHP and "integrated" by means of an iframe embedded into Sharepoint; not ideal.
I'm looking to understand the use of Sharepoint in this context. I believe that you can write Sharepoint Applications which are more "native" to Sharepoint than the rough-and-ready iframe approach I discussed before. How easy is it to take a standard ASP.NET MVC application and fully integrate it into Sharepoint?
Does anyone have any thoughts, experiences, or resources on this matter?
I think the first question is what kind of integration with SharePoint are you trying to accomplish? The simplest is to use the Page Viewer webpart (i.e. iframe) method. You can also write custom webparts that show data from your custom application. That's a form of integration. The ultimate form of integration, of course, is to make your application run inside of SharePoint. That leads to my next point.
SharePoint (as of version 2007) is essentially a giant ASP.NET framework. So you can theoretically use it to host any ASP.NET web application. I have actually done it before and it works. However, that was a plain old ASP.NET webforms application (not MVC). If this is what you are trying to do, you definitely would need to rewrite your php application in ASP.NET.
In Sharepoint there is a Page Viewer webpart using which you can load a different url. This way you can easily "integrate" your application to sharepoint site ;-)
But if you are really looking at Re Engineering the application in SharePoint then its a different story. You have to study the current application and then develop it in SharePoint.
This fellow has an approach to writing PHP for SharePoint. A key statement:
There are two big tricks – getting the
XML right and using NTLM
authentication.

Newbie Sharepoint website question

I am used to building java web applications.
I am used to MCV.
As I learn how to build a Sharepoint site, is it ok to think of building Sharepoint sites similarly, particulary where there is business logic layer, that, for instance, would grab data from various DBs, do some logic, then go to a certain page?
SharePoint and MVC do not play well together, not in a supported way at least. This isn't going to change for 2010 either. It's an ASP.Net Web Forms app, and so acts accordingly.
There is a Open Source Project for SharePoint MVC but you need to understand the plataform first, with some SharePoint for Developers tutorials.

Develop SharePoint web parts in ASP.NET [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have been asked to develop some usercontrols in ASP.NET that will at a later point be pulled into a SharePoint site as web parts. I am new to SharePoint and will not have access to a SharePoint server during the time I need to prototype these parts.
Does anyone know of any reasons that this approach will not work?
If this approach is not recommended, what would other options be?
Any suggestions on a resource/tutorial on what to consider when developing an ASP.NET web part with SharePoint in mind?
Thanks
Edit: 12/31/2008
I finally marked an answer to this one. It took me a while to realize that going the SharePoint route right away, though painful at first, is the best way to go about it. The free VPC image makes getting set up to develop relatively painless.
While you can, as I did, develop web parts in ASP.NET without SharePoint, when it comes to developing and deploying SharePoint applications you haven't learned a thing, only pushed the learning curve off into a time when you think you are done, (and have probably informed stakeholders to that effect). To delay the SharePoint learning curve doesn't do you or your project any favors, and your final product will better for the expertise you gain along the way.
ASP.NET web parts work in SharePoint the same as they work in ASP.NET. That's the route I would take (custom control that derives from the ASP.NET Web Part class). This will alleviate any requirement to actually develop on a SharePoint server.
The only issue you are going to encounter is that you will not be able to take advantage of the SharePoint framework. If you are doing anything advanced in SharePoint this is a big deal. However, SharePoint is ASP.NET plus some additional functionality, so anything you can develop using the System.Web.UI.WebControls.WebPart class should work great in SharePoint.
Some considerations that will help ease your pain as you go from pure ASP.NET to SharePoint:
If you can put everything inside of a single assembly, deployment will be easier
try to put everything you need into the DLL's that are deployed to SharePoint
use assembly resources to embed JS, CSS, and image files if needed
Strong name the assembly you are building
Most SharePoint deployments end up in the GAC and a strong name will be required
Here is a relevant blog post; Developing Basic Web Parts in SharePoint 2007
If it's a very short-term thing, Microsoft has a time-limited WSS evaluation VPC image:
WSS3 SP1 Developer Evaluation VPC image
That will get you started if you don't have time/resources to set up your own VPC image right now.
I guess the easiest way is to use the SmartPart for SharePoint from CodePlex. The project description says "The SharePoint web part which can host any ASP.NET web user control. Create your web parts without writing code!", which I guess is exactly what you want to do.
Setting up my machine to develop for Sharepoint took me a couple of days.
See http://weblogs.asp.net/erobillard/archive/2007/02/23/build-a-sharepoint-development-machine.aspx
Build and test the control as you would for a typical .net web site.
Solution 1 = the controls
Solution 2 = dummy website to host the controls.
Deployment on Sharepoint:
You'll need to sign the controls.
Drop the signed DLL into the GAC on the sharepoint server (Windows/assembly)
Mark the control as safe in the virtual server root web.config on the sharepoint site.
i.e.
<SafeControl Assembly="MyControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=975cc42deafbee31" Namespace="MyNamespace" TypeName="*" Safe="True" AllowRemoteDesigner="True" />
Register the component in your sharepoint page:
<%# Register Namespace="MyNamespace" Assembly="MyControl, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=975cc42deafbee31" TagPrefix="XXXX" %>
Use the control:
<XXXX:ClassName runat="server" Field1="Value1" Field2="Value2" ....></XXXX:Classname>
If you need to replace the control using the same version number, then you'll need to recycle the app pool to reload.
If you don't need to do anything SharePoint-specific (ie accessing lists, other webparts, etc) then you can build your webpart just like a regular webpart (derived from System.Web.UI.WebControls.WebParts.WebPart class) and it will work when added to a SharePoint site.
you need to have access to a sharepoint server because you can't simulate your webpart without it, you have to deploy it to your sharepoint site to test if it's working. debugging would also be a pain. or you can use SmartPart, it's a webpart that acts like a wrapper for your user controls to display in a sharepoint site.
You do not need SharePoint to develop WebParts. You can develop webparts by inheriting from the System.Web.UI.WebControls.WebParts. And this is the preferable way of creating web parts unless you want the following features like
* Connections between web parts that are outside of a Web Part zone
* Cross page connections
* A data caching infrastructure that allows caching to the content database
* Client-side connections (Web Part Page Services Component)
In which case you need to develop webparts by inheriting from Microsoft.SharePoint.WebPartpages.WebPart. You can find more useful info here
Is there any particular reason why your user controls must be deployed as web parts? It is perfectly feasible to deploy user controls directly to Sharepoint sites either through the CONTROLTEMPLATES folder in the 12 hive or to a location in the web app virtual directory, which you can then reference from web pages using Sharepoint Designer.
If however the web part requirement is crucial then I recommend Smartpart for Sharepoint as already mentioned.
Actually, Web Parts should always be deployed to the sharepoint's bin folder due to their 'abusive' nature. Always deploy web parts to the bin if possible and write your own CAS and include it in your manifest.

Resources