关闭

sharepoint2010 webpart开发心得

标签: sharepoint2010textboxassemblybuttonstring
623人阅读 评论(1) 收藏 举报
分类:

1.建接口,接口文件结构为获得传递的参数。将按口文件拖进行强签名放到服务器的windows/assembly 下。

2.consumer部件:

[ToolboxItemAttribute(false)]
    public class webcs : WebPart
    {
        Label lbl;
        Iwebcon iwe = null;
        [ConnectionConsumer("get param", "get param")]
        public void getparam(Iwebcon _iweb) {
            iwe = _iweb;
        }
        public webcs()
        {
            this.Title = "webcs";
            this.ExportMode = WebPartExportMode.All;
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            lbl = new Label();
            if (iwe != null)
            {
                lbl.Text = "GET.."+iwe.sendparam;
            }
            else
            {
                lbl.Text = "GET..";
            }
            this.Controls.Add(lbl);

        }
    }
}

3.provider部件:

   [ToolboxItemAttribute(false)]
    public class webprovider : System.Web.UI.WebControls.WebParts.WebPart,Iwebcon
    {
        protected string _sendparam = "";
        public string sendparam
        {
            get { return _sendparam; }
        }
        TextBox txt;
        Button btn;
        [ConnectionProvider("sendparam", "sendparam")]
        public Iwebcon connectionparam()
        {
            return this;
        }
        public webprovider()
        {
            this.Title = "Web Provider";
            this.ExportMode = WebPartExportMode.All;
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            txt = new TextBox();
            txt.Text = "";
            btn = new Button();
            btn.Text = "send...";
            btn.Click+=new EventHandler(btn_Click);
            this.Controls.Add(txt);
            this.Controls.Add(btn);

        }

        void btn_Click(object sender, EventArgs e)
        {
            this._sendparam = txt.Text;
        }


    }
}

 

[assembly: CLSCompliant(false)]

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:384757次
    • 积分:5407
    • 等级:
    • 排名:第4943名
    • 原创:138篇
    • 转载:133篇
    • 译文:1篇
    • 评论:35条
    最新评论