-2

I have an exam to create a WEB PART with SharePoint 2007 with the help of Visual Studio 2010 and import this web part in my site. What are the steps for creating web part with VS 2010?

enter image description here

Thank you previously!

1

Usually we use wsp builder from codeplex to develop the web parts for MOSS 2007. VS 2010 is used for SP 2010 product. There is no visual web part feature in MOSS 2007.

https://tallday.wordpress.com/2010/12/16/developing-sharepoint-2007-webparts-using-visual-studio-2010/

CONTENTS: So i presume your reading this because you love the new Visual Studio 2010 but need to develop web parts for SharePoint 2007. Although the interface within Visual Studio doesn’t directly enable you to develop for 2007, it is possible with some minor changes to your project.

So for the purposes of this article I am going create a basic visual web part, something that was difficult to do in SharePoint 2007 development. This process should work for most project types available… 1.Start New Project, select Visual Web Part

2.Select – Deploy as a farm solution 3.Write your custom web part. I have just created a simple web part that contains some text and a button. When the user clicks the button the button text will change. 4.I now press F5 on the keyboard and Visual Studio will automatically build & deploy my web part to SharePoint 2010. 5.I confirm it all works by adding the web part to the page. Great! But there is nothing special so far.

6.Now to get it into SharePoint 2007! First lets try deploying the current wsp as it is… 7.So we need to package up the solution. 8.Grab the wsp from the bin folder 9.Copy to SharePoint 2007 server. 10.Deploy to 2007 env and we get an error. The error tells us that it found a version number in the manifest that it doesnt understand.

“Solution manifest for solution ’48cae4c9-68ba-cccf5a89304′ failed validation, file manifest.xml, line 2, character 110: The ‘SharePointProductVersion’ attribute is not declared. Solution

After the steps above: 1.Go back into Visual Studio 2010. 2.Double click the “Package.package” file 3.Select “Manifest” down the bottom. Notice where is reads SharePointProductVersion=”14.0” in the xml file.

4.In the properties panel, clear out 14.0 in the SharePointProductVersion field. This removes the property all together from the manifest file. 5.We also need to change the assembly reference in the project from Microsoft.SharePoint.dll 14.0 to 12.0. To do this you will need to click the show all files icon in the solution explorer panel. image

-Next, delete out Microsoft.SharePoint & delete out Microsoft.SharePoint.Security as these wont be on the SP 2007 environment.-Then you want to add a reference to Microsoft.SharePoint.dll but make sure its the 12.0 version found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll

6.Because we have built a ‘Visual Web Part’, Visual Studio 2010 automattically adds some imports into the ascx user control file which wont exists in SP 2007. Therefore you need to comment these references out. Obviously if we were doing a coded web part or a event receiver we would not need to do this step.Mine currently looks like this.

Notes: ◾You will need Asp.Net 3.5 installed on your SharePoint 2007 environment. ◾This may not always be the right solution for you (depending on your project) but it certainly saves me a lot of time for those basic web parts.

you can try the above blog's contents approach. I have not tried though. The project references the assemblies for SharePoint 2010, not 2007. Here is a way to deploy visual webparts to SharePoint 2007, but it involves removing these references and replacing them with references to the SharePoint 2007 assemblies. Take a look at this article for more information http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/16/visual-web-parts-in-moss-2007.aspx

Corey roth has detailed steps on this:

Visual Web Parts in MOSS 2007

Yesterday, I showed you how to deploy a regular web part to MOSS 2007 / WSS3 that was built and packaged in Visual Studio 2010. Today, we can take that a step further and take advantage of the new Visual Web Part and deploy it the same way. If you remember, a Visual Web Part is nothing more than a glorified user control. To get started, create a new empty SharePoint project or use and existing one. If you need assistance with that, look at yesterday’s post. Then, go ahead and create a new Visual Web Part. The user control Visual Studio creates has many references to SharePoint 2010 DLLs that we simply do not need (or can use). These must be removed. Here is what it looks like when we start.

Remove any reference to a SharePoint version 14 DLL and you will have a file that looks like this. Then I’m just going to add a simple label to demonstrate our user control. Here is what it looks like after the changes.

      <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
            <%@ Register Tagprefix="asp" Namespace="System.Web.UI" 
         Assembly="System.Web.Extensions, Version=3.5.0.0, 
         Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
         <%@ Import Namespace="Microsoft.SharePoint" %> 
        <%@ Control Language="C#" AutoEventWireup="true"  
             CodeBehind="VisualWebPart1UserControl.ascx.cs" 
           Inherits="WSSWebPart.VisualWebPart1.VisualWebPart1UserControl" 
            %>
            <asp:Label ID="MyLabel" runat="server" Text="Hello, world!  
            Visual Web Part compiled in Visual Studio 2010!" /> 

You can replace, the version 14 references with version 12 references if you really need them. However, I find that most of the time, I am really only using standard ASP.NET controls so they are unnecessary. That is all you have to do. Assuming you started with a solution from yesterday, you can package the project and install the .wsp file on your SharePoint 2007 server using STSADM. If you created a new project don’t forget to remember to remove the SharePoint version attribute in the Package properties (discussed in yesterday’s post). Here is what my Visual Web Part looks like running on SharePoint 2007.

Let us know the results.

more links talks about the same:

VS-2010-for-MOSS-2007

DEPLOY-VISUALWP-in-MOSS-2007

  • On first step give me error... – Goshky Mar 24 '16 at 9:34
  • There is something simple way to create a project of SharePoint... – Goshky Mar 24 '16 at 9:35
0

You NEED SharePoint server on your LOCAL machine to create web parts. You can try with SharePoint Foundation its free and straight forward.

Download SharePoint Foundation 2013

  • What is the way to avoid these procedures. The question is to write a WebPart for Sharepoint 2007, which VS to install ?? – Goshky Mar 24 '16 at 12:00
  • i do believe there is no way around :( 1. install VisualStudio 2. install Sharepoint Server on LOCAL machine 3. create Web Part – ZaCk Mar 24 '16 at 12:10
  • I have a system of SharePoint 2007 and need to do a new module to it, how there is no way .. – Goshky Mar 24 '16 at 12:12
  • I Have VisualStudio 2010 and SharePoint 2007 – Goshky Mar 24 '16 at 12:13
  • is the SharePoint on the same Local machine as Visual Studio? – ZaCk Mar 24 '16 at 12:13
0

Problem is SOLVED!

1) Create "New Class Library";

2) Add reference System.Web.UI;

3) Copy -> visual studio 2010\Projects\HelloWorldWebPart\HelloWorldWeb\bin\Debug\HelloWorldWeb.dll IN Folder C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin

4) Add ---> SafeControl Assembly="-NameOfAssembly" Namespace="-NameOfNameSpace" TypeName="*" Safe="True" in web.config

5) GO to SharePoint "Site Settings"--> Galleries ---> Web Parts ---> New ---> Add the assembly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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