安装SPS的过程非常顺利,这里就不说了!
我来制作自己的第一个webpart!
1.请先安装Web Part Templates for Visual Studio .NET 下载
2.安装好以后,打开VS.NET 2003。在新增项目的对话框中找到Web Part Library,新增一个webPart,我取名[FlWebPart1],新生成的代码如下:
点此看大图
3.编译生成的FlWebPart1.dll就是我们的第一个WebPart。好了,按照网上的资料我作个如下改动:
protected override void CreateChildControls()2
{3
myUserControl = this.Page.LoadControl("/bin/myWebPart1.ascx");4
base.CreateChildControls ();5
}6

7
8
/// 9
/// Render this Web Part to the output parameter specified.10
/// 11
/// The HTML writer to write out to 12
protected override void RenderWebPart(HtmlTextWriter output)13
{14
this.EnsureChildControls();15
output.Write(SPEncode.HtmlEncode(Text));16
if ( myUserControl != null )17
{18
myUserControl.RenderControl(output);19
}20
21
}4.在代码中你一定看到了一个"/bin/myWebPart1.ascx",这个其实就是一个传统的Web UserControl,跟它相关的.cs文件是webpart不需要的(ps:有几头牛上一这么说的)。怎么把UserControl跟.cs文件脱离呢:
<%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%><%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

看去掉Codebehind, Inherits属性就可以了。
5.在UserControl控件中拖入各种控件,我拖的是微软日历控件
6.重新编译WebPart项目。
