Sun Application Server Startup Command: /opt/SUNWappserver/bin/asadmin start-domain --domaindir /opt/SUNWappserver/domains --user admin

Thursday, April 05, 2007

Create Web Part "HelloWorld" to SharePoint 2007

1. Open Visual Studio and create an new project.
2. Choose Web Part as picture:
3 Edit content in HelloWorld123.cs and program like:

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace HelloWork123
{
[Guid("a12d4678-34a5-4281-9d69-a3ab28a30c59")]
public class HelloWork123 : System.Web.UI.WebControls.WebParts.WebPart
{
public HelloWork123()
{
this.ExportMode = WebPartExportMode.All;
}
protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
writer.Write("Hello Hello Ha..Ha..Ha..");
}
}
}

4. Right click on Project HelloWorld123 and choose property

Choose correct browser with URL. 5. Hit F5 to start debug. or go to cmd(command window), cd to your project location. For example, here is C:\dev\SharePoint\HelloWorld\HelloWork123\HelloWork123\bin\Debug>
execute setup.bat. This will give the detail of deply process.
6. Go to SharePoint 2007 and go to the page I want to add a web part
7. Click on Add a new web part and we can find HelloWorld123 are on the list.

No comments: