Monday, February 22, 2010

How to Create and Deploy a web part in sharepoint using WSPBuilder (.wsp) ?

Introduction.

        A Web Part (also called a Web Widget) is an ASP.NET server control which is added to a Web Part Zone on Web Part Pages.

        Web Parts can be used as an add-on ASP.NET technology to Windows SharePoint Services.

Steps : 

        Following is step - step instructions as how to create a deployable WebPart (.wsp) file by using WSPBuilder.

         Before we start, please make sure you have following pre-requisites:

                1. WSPBuilder (SharePoint WSP tool) download here
                2. Microsoft.SharePoint.dll

  1. Start Visual Studio 2008.

  2. On the File menu, point to New, and then click Project.


  3. In the New Project dialog box, click Visual C# Projects -> WSPBuilder , and then select the WSPBuilder Project, Click OK.




  4. Now you got empty WSPBuilder Projcet. then Right-Click the Project select Add->New Item in popup menu. We got Add new Item dialog box, In that dialog box  select category as "WSPBuilder" and Template as "web Part Feature". Then click Add button.




  5. Now we got Feature Settings Dialog box. Which will allow you to set the Web Part Title,Description & Scope. After set those values click OK.




  Now we can see all the template files.




   Now we can explore the default files.

 






  6. Once we build the Project we got the deploy-able .wsp file.



   In Top of the solution explorer click the "show all files" Icon.


 



    Once we extract the .wsp file, It's look like this.




     Now we got deploy-able .wsp file.


Then we see How to deploy this file into Sharepoint?


  1. Copy and paste it in a common/Temp location.

  2. Register the solution file in to Sharepoint Database by using STSADM command line tool.


  3. After successful registration, we can see the solution in Central Adminstration -> Operations -> Global Configuration -> Solution Management.






  4. Click the Solution Management, we can see status as Not deployed because we registered the .wsp file, Not yet deployed.


  5. Click the Solution Link (*.wsp). We got the solution property page. In that page click the "Depoy Solution" menu and set the property based on our requirement.




  6. Click Ok and see the status of the solution.






  7. After the successful deployment we can see the feature files in Sharepoint hive Folder "12\Template\Features"








Now We can walk through, How to insert this we part in our Sharepoint Page?


  1. Goto Site Actions -> "Site Settings" page.Under"Galleries" tab click "Web Parts" link.


   




  2. Add a new web part, Click New menu in web part gallery Page.




  3. Select the newly added web part in the "New Parts Page" .








  We added our new web part in our site.

Now we see How to insert into a Sharepoint Page?


  1. Select the appropriate List, Then select "Site Actions" -> "Edit Page" .


 

  
 


  2. Click "Add a web part" link, and select our new web part from the web part template page.



  3. Click Add & see our web part added in the Sharepoint List Page.


 

 




I hope you enjoy this article.


Thank You.