一个简单的webpart

首先要安装moss的开发模板。
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 AjaxWebPart
{
    [Guid("ce204a6d-448c-426a-9f90-23a021020f66")]
    public class AjaxWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        Label label = new Label();
        TextBox tbx = new TextBox();
        Button btn = new Button();

        public AjaxWebPart()
        {
            label.Text = "Hello World budy";
            btn.Text = "show";
            btn.Click += new EventHandler(btn_Click);
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.

            this.Controls.Add(label);
            this.Controls.Add(tbx);
            this.Controls.Add(btn);

        }

        void btn_Click(object sender, EventArgs e)
        {
            this.label.Text = "hello " + tbx.Text;
        }

        private string path = string.Empty;
       
        [WebBrowsable(true)]
        [Personalizable(true)]
        public string Path
        {
            get { return path; }
            set { path = value; }
        }

    }
}

posted @ 2008-03-27 15:41  KID  阅读(241)  评论(0编辑  收藏  举报