sharepoint2010 webpart开发心得

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)]

 

 

阅读更多
个人分类: sharepoint 2010
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

sharepoint2010 webpart开发心得

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭