Skip to main content

Different ways to deploy webpart


Dear All, 
If you are facing a problem to deploy SharePoint through one way, Than Here I am writing different  ways to deploy the Customized Web Part Under SharePoint Portal

Here we go.... 


When you are done developing a WebPart, you need to deploy it to the SharePoint server. However, depending on your server setup, you may have to use specific deployment methodology and that is why it is important to know your options. This post describes different ways to achieve this goal.





Basic understanding

Whatever method you use to develop your WebPart, you will always end up with a WebPart DLL and in some cases you will have WSP file (both of these files are in debug folder of your project). It is the DLL file that plays a key role in getting your WebPart inside SharePoint server.

Ways to deploy a WebPart

There are more ways but i mentioned here four ways we can deploy a WebPart on SharePoint server that I will cover in this post:
  • Using Visual Studio to deploy the solution
  • Manually moving the DLL to the server
  • Uploading WSP to SharePoint server
  • Deploying through command prompt
  • Through Power shell for this please refer my following post (http://bvs-sharepoint.blogspot.com/2015/02/power-shell-scripts-to-install-your.html) 

Pre-Requisites

I am assuming that you are all done with the development and are now ready to deploy. In these examples I have a project name "FeedbackWP" that I need to deploy.

Method - 1: Deploying through Visual Studio

Once the coding is complete, click on build > deploy



In the output window you should see the deployment success status.



For next steps please look at "After you webpart is deployed" section at the end of this post.

Method 2: Deploying by manually moving the DLL

Build the solution




If no error returned by the compiler, copy the DLL from your project bin > Debug directory to the bin directory of your WSS site (C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin).

 > 


Go to (C:\inetpub\wwwroot\wss\VirtualDirectories\80\) and modify the Web.Config file for the WSS site to declare the custom web part as a safe control by adding the following code within the <SafeControls> tag.

<SafeControl Assembly="DLL-Name-Here" Namespace="DLL-Name . NameSpaceHere" TypeName="*" Safe="True" />

In my case my dll name is feedBackWP and the namespace of my webpart is InputForm; so my SafeControl entry looks like:

<SafeControl Assembly="feedBackWP" Namespace="feedBackWP.InputForm" TypeName="*" Safe="True" />
And my webconfig looks like the image below:



Now we need to add this webpart to our Sharepoint gallery.
Click on Site Actions -> Site Settings -> Web Parts.






From Web Parts page click on Documents > New Document




New Document will bring up a pop-up window. This window should have your new web part listed. Select your webpart from the list and click on Populate Gallery.


If the import is successful, you will see the web part in Web part gallery list.


For next steps please look at "After you webpart is deployed" section at the end of this post.

Note: If you want to done some changes and want to update the webpart just update the dll in your wss bin directory


Method 3: Deploying by uploading WSP to SharePoint server

Build the solution


If no error returned by the compiler, you will have WSP file in your project bin > Debug.

Open Sharepoint and click on Site Actions -> Site Settings -> solutions.


From solutions page click on solutions on top and after clicking it, you should see upload solution tab.





Click on upload solution and it will bring up a popoup to upload your webpart.


Upload your WSP file.



If uploading is successfull, you should see the webpart appear in the solutions list.


Activate the solution and thats it.




For next steps please look at "After you webpart is deployed" section at the end of this post.

Method 4: Deploying through command prompt

Build the solution


If no error returned by the compiler, you will have WSP file in your project bin > Debug.

Copy the wsp file on the server and open up a command line and navigate to the 12-hive bin folder.
(my 12-hive bin folder is C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN)



Enter the following commands :
stsadm -o addsolution -filename WSP FILE NAME WITH LOCATION

stsadm -o deploysolution -name WSP FILE NAME -immediate -allowGacDeployment -url SITEURL
So in my case these commands become:
stsadm -o addsolution -filename c:/feedBackWP.wsp
stsadm -o deploysolution -name feedBackWP.wsp -immediate -allowGacDeployment -url http://bk-laptop-hp/



For next steps please look at "After you webpart is deployed" section.

After your Webpart is deployed

Go to the SharePoint site and click on Site Action > New Page.










From new page click on Insert and then on WebPart.






From WebPart list click on custom (NOTE: In some cases this is miscellaneous instead of custom). This should bring up our WebPart on the right hand side.


With the WebPart selected click on the add button.


Your webpart will be there 

Regards 
Rashid Imran Bilgrami 

Comments

Popular posts from this blog

Content Query Webpart Template In SharePoint 2013 and add new column in it

Dear All, Here is the easiest way to make add custom column under your content query web part and then you can format it as you want. Step 1:  Open Sharepoint design Step 2:  Open site for sharepoint parent site collection Step 3:  Locate the following folder Style Library > XLS Style Sheets Step 4:  Open "ItemStyle.xsl"  file Add the custom style sheet as you want <xsl:template name="[Your Style Name]" match="Row[@Style='[Your Style Name]']" mode="itemstyle">                                                   <xsl:param name="CurPos" />                                                     <xsl:variable name="SafeLinkUrl">                                                       <xsl:call-template name="OuterTemplate.GetSafeLink">                                                         <xsl:with-param name="UrlColumnName" select="'LinkU

Updatepanel or Enable Ajax in SharePoint webpart

Dear All It is really giving me a hard to get this techniques if you want to run the update panel in sharepoint 2013 webpart then you need to initialize the script manage by code   protected override void OnInit(EventArgs e)         {             base.OnInit(e);             InitializeControl();             // Register the ScriptManager             ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);             if (scriptManager == null)             {                 scriptManager = new ScriptManager();                 scriptManager.ID = "ScriptManager1";                 scriptManager.EnablePartialRendering = true;                 Controls.AddAt(0, scriptManager);             }         } In ascx page you need to add the following  <asp:UpdateProgress ID="UpdateProgress1" runat="server">     <ProgressTemplate>         <h1>Your progress value</h1>     </ProgressTemplate> </asp:U

SharePoint: A Complete Guide to Getting and Setting Fields using C#

Original article https://social.technet.microsoft.com/wiki/contents/articles/21801.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-c.aspx Introduction This article demonstrates how to set and get the various SPField types for a SharePoint list using C#. The examples demonstrated set and get fields from an item that belongs to a custom list. The custom list contains a number of fields, and all the fields are named based on the type of field they are. For example, there is a Text field, which has been named, textfield. This is depicted in the following picture:   Applies To The examples demonstrated below are tested with and apply to the following versions of SharePoint: SharePoint 2010 SharePoint 2013 Get the List, and the first SPListItem This is the basic code for getting an item. If the list has at least one item, the first item is retrieved, otherwise a new item is created. var web = SPContext.Current.Site.RootWeb; var list = web.Lists.Try