分享

Developing Web Parts for SharePoint Portal Server 2003 in .NET(一)

 wuhy80 2006-01-05
harePoint allows information workers to create powerful personalized interfaces by simply dragging and dropping pre-defined Web Part Components. Web Parts are components that enable non programmers to gather information they care about and customize the appearance of Web pages. For example, one Web Part might display a user‘s appointment calendar; another might create a graph showing current sales figures; and a third might show a list of new business topics, each of which functions as a link to a video or audio presentation. Developers can create these Web Part components and make them available to SharePoint users, letting them build customizable pages that meet their needs. This article shows you how to build and consume a simple Web Part.


Web Part Templates for Visual Studio .NET
Web Parts are standard ASP.NET custom controls, but Microsoft has provided a new template that simplifies the process of creating Web Parts. You can download the template here .

You need to install the template only once, after which it will be available permanently in the Visual Studio .NET environment.

Installing the Web Part Template.
After downloading the template, locate the file WebPartTemplates.exe, and double click on it to install the templates. The templates support both C# and VB.NET development—choose the target language or languages that fit your requirements. (see Figure 1)

 
Figure 1: During the Web Part template installation, you can elect to install the templates for either Visual C#, Visual Basic .NET, or both.

After selecting the Web Parts templates language, you‘ll need to select the location of the Microsoft.SharePoint.dll file. By default, SharePoint installs the Microsoft.SharePoint.dll to local_drive:\Program Files\Common Files\Microsoft Shared\Web server extensions\60\ISAPI; however, you may have installed SharePoint to a non-default location.

When you‘re developing locally with Visual Studio .NET, the .NET Framework, and SharePoint installed on same machine, you can simply provide the path to the local copy of the DLL. On the other hand, if you‘re developing on a local machine and connecting to a remote server hosting SharePoint, you‘ll find it easier to copy the DLL to your local machine and use that local DLL location. This article assumes that you‘re developing on a machine with both .NET and SharePoint installed locally (see Figure 2).

 
Figure 2: When asked to specify the Microsoft.SharePoint.dll path, provide the full path, but not the file name.

After installing the templates, every time you create a new Web Part application, Visual Studio will automatically add a reference to the SharePoint DLL to the Web Part project (see Figure 3).

 
Figure 3: The Solution Explorer in Visual Studio .NET after adding the Microsoft.SharePoint.dll reference.

On the other hand, if you don‘t provide the location for the DLL during installation, VS .NET pops up the following message every time you create a new Web Part application (see Figure 4).

 
Figure 4: You‘ll see this message if you don‘t specify the correct Sharepoing.dll location during installation.

Despite the message text, all that really means is that you‘ll have to add a reference to the DLL manually.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多