Skip to main content

Web part Deployment Guide

Step By Step Web Part Deployment Guide



Following deployment of sharepoint webpart applied to
WSS 3.0/MOSS 2007 using MS Visual Studio 2008

Web Part Dployment Steps:

Step 1: File-New-Project-C#-Class Library Project

Step 2: Add Reference
right click on project and click on “addreference”.
Add “System.web” from “.Net” tab.

Add another reference named “Microsoft.Sharepoint” by browsing from “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5” directory

(copy “Microsoft.sharepoint.dll” file into “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5” directory to use it.)

Step 3: Class file coding:

add following reference into the class file:

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebPartPages;

Inherit class from “Webpart” class:

public class Class1 : WebPart

Complete class fie code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace wp2
{
public class Class1 : WebPart
{
protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write(“Hi ” + this.Context.User.Identity.Name);
}
}
}

Step 4: To set the version number and allow partially trusted callers

1.    In Solution Explorer, double-click the AssemblyInfo file
2.    Edit the line:

C#
[assembly: AssemblyVersion(“1.0.*”)]

Visual Basic

so that it reads:

C#
[assembly: AssemblyVersion(“1.0.0.0”)]

Visual Basic

3.    Add the following line to the top of the file:

C#
using System.Security;

Visual Basic
Imports System.Security;

4.    Add the following line to the bottom of the file:

C#
[assembly: AllowPartiallyTrustedCallers]

Visual Basic

Project file Property settings:

Now right click on project file and click on “properties”.
Now go into the “build” tab and set “output path” as the server’s sharepoint bin directory like “\\[sharepoint path with port]\Inetpub\wwwroot\wss\VirtualDirectories\dbvss80\bin\”
(this will create dll of this project into the output directory)

Web Config Settings:

add the following code into SharePoint web config file:
(Webconfig is into the “\\[sharepoint path with port]\Inetpub\wwwroot\wss\VirtualDirectories\dbvss80” directory)
add “” between “” section.

Use of Web Part into SharePoint Site :

Click on “Site Action”->”Site Settings”-> go to “Galleries” section and click on “Web Parts”

Now you can see the web part list on page. To add new web part click on “New” link on top.

Now you can see the all “safe web parts” in list selected related webpart from list and click button “Populate Gallery” from top.

Now you are ready to use Web part…

just edit page and click on “Add webpart section” and select related web part from list. (most of new web parts are under the “miscellaneous” section.)

Enjoy Web part development.

Comments

  1. even after deployment when I click on the webpart I am getting error as "webpart cannot be displayed or imported.the type is not registered safe "
    But I have registerd it as safe

    ReplyDelete
  2. SafeControl Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=################" Namespace="MyWebParts" TypeName="*" Safe="True"

    ReplyDelete
  3. We absolutely love your blog and find many of your post's to be exactly what I'm looking
    for. Do you offer guest writers to write content in your case?
    I wouldn't mind publishing a post or elaborating on a few of the subjects you write regarding here. Again, awesome website!
    Also see my website :: safe diets

    ReplyDelete

Post a Comment

Popular posts from this blog

Tab Control in Asp.Net

Scenerio: I need your help in designing tab control in   asp.net .My requirement is I need a tab control in   asp.net (C#) like  for example goto my computer ,right click c drive and select properties.we get tabs like general,security etc....... like that i need to design one tab control(no need of any rightclick) in my web page and the database table columns should come as tabs and inseide the tab data of that particular column should come.   Example:Employee master tab1:Employee name.........his name in the tab tab2:Age.............his age tab3:Address........his address   Solution:   You can do this using a simple div <style type="text/css"> .tabs         {             position: relative;             height: 20px;             margin: 0;   ...

AI and Microsoft: Revolutionizing Efficiency in Nonprofit Organizations

  How AI and Microsoft Enhance Efficiency in Nonprofit Organizations In today’s fast-paced world, nonprofit organizations face unique challenges—limited resources, increasing demands, and the constant need to do more with less. But what if technology could be the game-changer they need? In my latest research paper,  "How AI and Microsoft Enhance Efficiency in Nonprofit Organizations" , I explore how cutting-edge technologies like Artificial Intelligence (AI) and Microsoft’s innovative tools are revolutionizing the way nonprofits operate. From streamlining administrative tasks to enhancing donor engagement and optimizing resource allocation, AI and Microsoft’s solutions are empowering nonprofits to focus on what truly matters—their mission. This paper dives deep into real-world examples, practical applications, and the transformative potential of these technologies. Whether you’re a nonprofit professional, a tech enthusiast, or simply curious about the intersection of technolo...

Social tagging overview in Sharepoint 2010

A tag is a word or phrase that identifies an individual piece of information according to a set of attributes or criteria. Tags make it easy to find and share information about a specific subject or task. Social tagging helps users categorize information in ways that are meaningful to them. Social tagging can improve the quality of search results by filtering against specific tags, and it can also connect individuals who want to share information with other users who have like interests. This article describes the social tagging features in Microsoft SharePoint Server 2010. This article does not describe how to configure social tagging features. It also does not discuss how to implement social tagging features as part of an overall social media strategy for an enterprise. About using social tagging features Social tagging features help users to share information and to retrieve relevant, high-quality content more efficiently. Such sharing encourages collaboration and b...