Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a web part that I have been deploying to Server A. I now have a new SharePoint environment I would like to deploy my web part to (Server B). How can I set the web part solution to deploy to Server B rather than Server A? I have done this before but cannot find the place to do it.

Thanks.

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

If you select the Project in the Solution Explorer, from the Properties window below you can set the SharePoint site to deploy to.

share|improve this answer
    
I cannot find this. I have clicked Properties on the Solution and the Project. Are you talking about right clicking and selecting Properties? –  Anonymous Aug 10 '10 at 15:57
2  
Okay found it. Had to click the properties window rather than right clicking and selecting properties. –  Anonymous Aug 10 '10 at 16:08
    
I am now getting this error: Error 1 Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site: server/realestate. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project. 0 0 Is this probably because VS2010 is not installed on the SharePoint server? –  Anonymous Aug 10 '10 at 16:11
1  
I'm not sure if you're able to deploy to a remote system from within visual studio - the environment is intended for development on the local system. IF you wish to deploy the solution to another system you will have to locate the WSP file produced by visual studio and manually deploy it using stsadm. –  James Love Aug 10 '10 at 16:28
2  
stsadm will need to be run locally on the server to which you're deploying. –  James Love Aug 10 '10 at 17:08
show 1 more comment

Steps to create and deploy a Visual WebPart:

  1. Start Visual Studio 2010, click File -> New -> Project.
  2. Navigate to the Visual C# node in the Installed Templates section, click SharePoint, and then click 2010.
  3. Select the Visual Web Part project template and provide a name (such as, SampleWebPart), a location for your project, and then click OK.

    using System;
    
    using System.Web.UI;
    
    using System.Web.UI.WebControls;
    
    using System.Web.UI.WebControls.WebParts;
    
    using Microsoft.SharePoint;
    
    
    
    namespace SampleWebPart.VisualWebPart1
    
    {
    public partial class VisualWebPart1UserControl : UserControl
    
    {
    
        protected void Page_Load(object sender, EventArgs e)
    
        {
    
            SPWeb thisWeb = null;
    
            TreeNode node;
    
            thisWeb = SPContext.Current.Web;
    
            //Add the Web's title as the display text for the tree node, and add the URL
              as the NavigateUri.
    
            node = new TreeNode(thisWeb.Title, null, null, thisWeb.Url, "_self");
    
            //The Visual Web Part has a treeview control called siteStructure.
    
            siteStructure.Nodes.Add(node);
    
            //Get a reference to the current node, so child nodes can be added in the
              correct position.
    
            TreeNode parentNode = node;
    
            //Iterate through the Lists collection of the Web.
    
            foreach (SPList list in thisWeb.Lists)
    
            {
    
                if (!list.Hidden)
    
                {
    
                    node = new TreeNode(list.Title, null, null, list.DefaultViewUrl,
                                                                              "_self");
    
                    parentNode.ChildNodes.Add(node);
    
                }
    
            }
    
            foreach (SPWeb childWeb in thisWeb.Webs)
    
            {
    
                //Call our own helper function for adding each child Web to the tree.
    
                addWebs(childWeb, parentNode);
    
                childWeb.Dispose();
    
            }
    
            siteStructure.CollapseAll();
    
        }
    
        void addWebs(SPWeb web, TreeNode parentNode)
    
        {
    
            TreeNode node;
    
            node = new TreeNode(web.Title, null, null, web.Url, "_self");
    
            parentNode.ChildNodes.Add(node);
    
            parentNode = node;
    
            foreach (SPList list in web.Lists)
    
            {
    
                if (!list.Hidden)
    
                {
    
                    node = new TreeNode(list.Title, null, null, list.DefaultViewUrl,
                                                                               "_self");
    
                    parentNode.ChildNodes.Add(node);
    
                }
    
            }
    
            foreach (SPWeb childWeb in web.Webs)
    
            {
    
                //Call the addWebs() function from itself (i.e. recursively)
    
                //to add all child Webs until there are no more to add.
    
                addWebs(childWeb, parentNode);
    
                childWeb.Dispose();
    
            }
    
        }
    
    }
    }
    

For more details please check out this link...

http://mindstick.com/Articles/9e1d1fe1-7e51-4d01-86ec-f1f679631a7e/?Create%20and%20Deploy%20Visual%20WebPart%20in%20SharePoint%202010

I hope it might be useful for you.

share|improve this answer
    
thanks for the detailed explanation of creating and deploying a web part in VS. Others will find this answer useful in the future. :) –  Russell Dec 22 '11 at 20:28
add comment
  1. open solution explorer
  2. single click on the desire project.
  3. press F4. a property window will open. From there you can change your site URL.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.