当前位置: 首页 » 电脑知识 » 电脑基础知识 » 正文

一步一步SharePoint 2007之二十三

发布时间:2025-06-23 以下文章来源于网友投稿,内容仅供参考!

编写一个最简单的WebPart(1)——创建工程

摘要

在前面的文章中,我们讲解了很多基础的内容,主要包括安装配置、Form认证等,

一步一步SharePoint 2007之二十三

。可能这些对 很多朋友来说,是太容易了。那么,从下一篇文章开始,就让我们进入SharePoint的高级课题之旅吧。

本篇文章将介绍如何编写一个最简单的WebPart。

跟所有的编程技术一样,都是从编写第 一个Hello World程序开始的。笔者自叹也是一个俗人,所以当然也不能免俗,我们就也从编写一个Hello World的WebPart开始吧!

正文

考虑到编写一个最简单的WebPart的文章共有20多幅截图, 截图总大小近2M,为了尽量减少打开网页的时间,本篇文章将被分割成几个小的部分。因此而给大家带来 的阅读不便,就请海涵了:)

本篇文章将创建一个WebPart工程。

为了方便您的学习,您可 以下载本篇文章所创建的工程。

下面将记录每一步的操作过程。

1、首先Visual Studio 2005,在菜单中依次选择File,New,Project。

2、单击Project后 ,即弹出New Project对话框。这里我们选择创建一个C#语言的Class Library工程,工程名称为 Eallies.WebParts.Hello。

3、新建工程完毕后 ,将默认的Class1改名为Instance,则整个工程就是这样的:

4、在右边的 Solution Explorer中,右键单击References,在弹出的菜单中选择Add Reference,则弹出Add Reference对话框。这里我们选ponent Name为System.Web。

5、添加完Reference 后,我们打开Instance.cs,将其代码更改为:

 1using System;  2using System.Collections.Generic;  3using System.Text;  4using System.Web.UI.WebControls.WebParts;  5  6namespace Hello  7{  8   public class Hello : WebPart  9   { 10     private string _Text = "Hello World!"; 11 12     [WebBrowsable(true), Personalizable(true)] 13     public string Text 14     { 15       get { return _Text; } 16       set { _Text = value; } 17     } 18     protected override void Render(System.Web.UI.HtmlTextWriter writer) 19     { 20       writer.Write(_Text); 21     } 22   } 23}

6、然后再打开Properties\AssemblyInfo.cs,将其代码更改为:

  1using System.Reflection;  2using System.RuntimepilerServices;  3using System.Runtime.InteropServices;  4using System.Security;  5  6// General Information about an assembly is controlled through the following  7// set of attributes. Change these attribute values to modify the information  8// associated with an assembly.  9[assembly: AssemblyTitle("Hello")] 10[assembly: AssemblyDescription("")] 11[assembly: AssemblyConfiguration("")] 12[assembly: Assemblpany("Eallies Corporation")] 13[assembly: AssemblyProduct("Hello")] 14[assembly: AssemblyCopyright("Copyright © Eallies Corporation 2006")] 15[assembly: AssemblyTrademark("")] 16[assembly: AssemblyCulture("")] 17 18// SettingVisible to false makes the types in this assembly not visible 19// toponents. If you need to access a type in this assembly from 20//, set theVisible attribute to true on that type. 21[assembly:Visible(false)] 22 23// The following GUID is for the ID of the typelib if this project is exposed to 24[assembly: Guid("8318200d-9059-4b4e-81db-c146659bd89d")] 25 26// Version information for an assembly consists of the following four values: 27// 28//   Major Version 29//   Minor Version 30//   Build Number 31//   Revision 32// 33// You can specify all the values or you can default the Revision and Build Numbers 34// by using the '*' as shown below: 35[assembly: AssemblyVersion("1.0.0.0")] 36[assembly: AssemblyFileVersion("1.0.0.0")] 37 38[assembly: AllowPartiallyTrustedCallers()]

这里,我们实际上只是引用了 System.Security,然后加上了[assembly: AllowPartiallyTrustedCallers()]这一行代码,《一步一步SharePoint 2007之二十三》()。

至此,WebPart工程 即创建完毕。

下一篇文章我将记录如何编写一个最简单的WebPart的第二部分。

本文配套源码:bianceng/do/201212/779.htm

  • • 一步一步SharePoint 2007之三十六

    在SharePoint中实现Workflow(2)创建一个Workflow摘要本篇文章将介绍在SharePoint中实现Workflow的第二部分创建一个Workflow,一

  • • 一步一步SharePoint 2007之三十七

    在SharePoint中实现Workflow(3)运行Workflow摘要本篇文章将介绍在SharePoint中实现Workflow的最后一部分运行Workflow,一步一步S

  • • 一步一步SharePoint 2007之三十五

    在SharePoint中实现Workflow(1)创建一个判断列摘要在安装SharePoint的时候,笔者就已经提到,要顺利安装SharePoint,必须首先安

  • • 一步一步SharePoint 2007之三十四

    实现通用Event Handler(2)尝试Event Handler摘要本篇文章将介绍实现通用Event Handler的最后一部分尝试Event Handler,一步一步S

  • • “NaPa” 开发SharePoint 2013 App

    搭建好SharePoint2013的环境,“NaPa” 开发SharePoint 2013 App。然后创建一个Developer Site在图中可以发现,2013多了个Develo

  • 中国国家地名信息平台
    牛游戏网
    wordpress官网登录入口
    wordpress中文官网入口
    王者霸业官网下载_王者霸业传奇手游下载
    腾讯电脑管家下载
    网页版qq登录入口
    chrome浏览器官网入口
    天天基金网
    东方财富网
    351121邮编查询,351121邮政编码查询
    351117邮编查询,351117邮政编码查询
    361004邮编查询,361004邮政编码查询
    351129邮编查询,351129邮政编码查询
    361104邮编查询,361104邮政编码查询
    351123邮编查询,351123邮政编码查询
    361102邮编查询,361102邮政编码查询
    351137邮编查询,351137邮政编码查询
    361111邮编查询,361111邮政编码查询
    351139邮编查询,351139邮政编码查询