【发布时间】:2011-01-13 07:41:42
【问题描述】:
我正在使用 Visual Studio 2008,并已下载 VSeWSS.exe 1.2,以启用 Web 部件开发。我是 SP 开发的新手,并且已经对不同版本的 SP 和 VS 附加组件的数量感到困惑。出现了这个特殊的问题,这凸显了我的困惑。
我选择了添加 -> 新建项目 -> Visual C# -> SharePoint-> Web Part,接受默认值,VS 创建了一个项目,主文件为 WebPart1.cs
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace WebPart1
{
[Guid("9bd7e74c-280b-44d4-baa1-9271679657a0")]
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
public WebPart1()
{
}
protected override void CreateChildControls() // <-- This line
{
base.CreateChildControls();
// TODO: add custom rendering code here.
// Label label = new Label();
// label.Text = "Hello World";
// this.Controls.Add(label);
}
}
}
我正在关注的书,Essential SharePoint 2007,作者 Jeff Webb,默认项目包含以下内容 -
using System;
<...as previously>
namespace WebPart1
{
[Guid("9bd7e74c-280b-44d4-baa1-9271679657a0")]
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
// ^ this is a new style (ASP.NET) web part! [author's comment]
protected override void Render(HtmlTextWriter writer) // <-- This line
{
// This method draws the web part
// TODO: add custom rendering code here.
// writer.Write("Output HTML");
}
}
}
我担心的真正原因是,作者在本书的这一章中经常提到“旧式”Web 部件和“新式”Web 部件之间的区别,正如他对 Render 方法的评论中所指出的那样。
发生了什么事?为什么我的默认 Web 部件的签名与作者不同?
【问题讨论】:
-
无关:版本 1.3 可用:microsoft.com/downloads/…
-
谢谢。我在安装 1.2 时遇到了一些麻烦,所以一旦它开始工作,我就不想冒险尝试 1.3。我查看了 1.3 的更改说明,它们似乎与此问题无关。由于 2009 年发布了 1.3,而我的书是 2007 年,因此我的 VSeWSS 或这本书的版本不太可能是 1.3。
-
我感觉他(作者的)代码是针对 VSeWSS 1.0 或 1.1 的,这就是他所说的“新风格”,而我的 1.2 代码是一种“新的新风格”,并取代它。仍在尝试查找此版本的“入门”指南。
-
我从来没有找到这个问题的答案。我被困在部署上,为了解决这个问题,我开始使用 WSPBuilder。它带有自己的默认 C# 项目,该项目生成一个“Hello World”Web 部件。它接近问题中的第一个程序。
标签: sharepoint-2007 web-parts wss-3.0 vsewss