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

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值