This posting has a new location:
http://dougortiz.blogspot.com/2009/06/developing-custom-web-part-with.html
With the release of Microsoft Visual Studio 2008 many SharePoint Developers will be interested in creating custom Web Parts for SharePoint. This is entirely achievable and not very different from how it is done within Visual Studio 2005.
While the avenues to accomplishing this are similar with Microsoft Visual Studio 2005, there are a few items to consider:
- <!–[if !supportLists]–>· <!–[endif]–>Visual Studio 2005 Extensions for Windows SharePoint Services is not available or compatible with Microsoft Visual Studio 2008
- <!–[if !supportLists]–>· <!–[endif]–>As a good practice, it is recommended to backup your project before converting it into Visual Studio 2008
Creating the Web Part Project can be done in two of ways:
- <!–[if !supportLists]–>· <!–[endif]–>Convert an existing template project from Microsoft Visual Studio 2005
- <!–[if !supportLists]–>· <!–[endif]–>Create the project from scratch
<!–[if !supportLists]–>o <!–[endif]–>Add the following references to the project:
System.Web;
Microsoft.SharePoint
<!–[if !supportLists]–>o <!–[endif]–>Add the following code to the top of the project
using System.Web;
using System.Web.UI;
using Microsoft.SharePoint.WebPartPages;
<!–[if !supportLists]–>o <!–[endif]–>Assign the class to inherit from the WebPart
public class MyCustomWebPart: WebPart
<!–[if !supportLists]–>o <!–[endif]–>Add the RenderWebPart code:
protected override void RenderWebPart(HtmlTextWriter output)
{
}
<!–[if !supportLists]–>o <!–[endif]–>Add desired code inside the “RenderWebPart”
<!–[if !supportLists]–>o <!–[endif]–>Determine deployment type: bin or Global Assembly Cache
<!–[if !supportLists]–>o <!–[endif]–>By default the Target Framework is 3.5
<!–[if !supportLists]–>o <!–[endif]–>Deploy the Custom Web Part