Building Web Parts for SPS读书笔记(1)

Building Web Parts for SPS读书笔记(1)

 

Web Part Library项目至少包含如下类型的文件:

(1)一个或多个 (*.cs or *.vb)包含继承Microsoft.SharePoint.WebPartPages.WebPart 的类文件。WebPart扩展 System.Web.UI.Control 类,WebPart是拥有扩展行为和状态的Server control

(2) 每一个Web Part类必须有一个对应的dwp文件。dwp是一个XML文件,包含描述Web Part的一些具体信息,如titledescription等等,更重要的是包含web part assembly的信息。dwp文件需要放置在Web Part library目录,这样web partportal用户可见。

(3) Web Part项目也需要包含一个manifest.xml文件,这个文件在部署Web Part时会使用到。它也包含需要并入到WSSSPS站点的web.config文件的一些配置信息(如标识该Web PartSafe Control)。

 

Web Parts开发

protected override void RenderWebPart(HtmlTextWriter output)

{

}

重载RenderWebPart方法,你可以通过使用RenderWebPartPortal页面产生表示Web PartHTML

 

protected override void CreateChildControls()

{

}

一个更好的方法是为Web Part control创建多个child controls,并让每一个child control生成自身的HTML。通过这种方法,可以为用户必要动作(actions)关联相应的事件句柄(event handler)。

server control通过重载CreateChildControls方法来创建child controls

 

部署Web Part

可以手动部署或通过STSADM.EXE工具自动部署Web PartSPS使用如下目录:

(1) Your assembly (web part assembly) can be dropped in the GAC or stored as a private assembly in the /bin directory.

(2) Your DWP files need to be dropped in the /wpcatalog folder

在使用Web Part时,可以通过访问virtual server library/SPS来托放Web PartSPS页面。

(3) Your resources should be placed in the /wpresources folder

(4) And finally, the web.config of the SharePoint site should contain an entry specifying that your Web Part is a safe control to be used on the portal pages.

STSADM.EXE工具可以为我们做上述工作,不过需要先创建cab文件,Stsadm.exe使用示范:

Stsadm.exe -o addwppack -f YourWebPartSetup.cab

 

References:

1. Patrick Tisseghem, Building Web Parts for Microsoft SharePoint Products and Technologies, Part I - The Basics, http://www.microsoft.com/belux/nl/msdn/community/columns/tisseghem/webparts1.mspx

2. Patrick Tisseghem, Building Web Parts for Microsoft SharePoint Products and Technologies

 

posted @   Rickie  阅读(1055)  评论(4编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示