SharePoint2010自定义工具栏

相信大家对自定义工具栏很有兴趣吧,在家里研究拉一下,把自己的代码给贴出来,给大家喜欢研究MOSS的哥们研究,研究 , 其实就是继承一个编辑类就OK拉,这个自定义工具栏,在实际的MOSS开发中,很有帮助的,很多地方需要他。。

//这个类是工具栏的编辑类,工具栏 ,主要靠他
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.WebControls;
namespace WebPartDemo { public class MyEditor : EditorPart     {       public MyEditor()       {          this.Title = "Custom Editor";       }
      
private PeopleEditor selPeople;
      
protected override void CreateChildControls()       {          selPeople = new PeopleEditor();          Controls.Add(selPeople);       }
      
public override bool ApplyChanges()       {          EnsureChildControls();          (WebPartToEdit as WebPartDemo).DefaultTitle = selPeople.CommaSeparatedAccounts;          return true;       }
      
public override void SyncChanges()       {          EnsureChildControls();          selPeople.CommaSeparatedAccounts = (WebPartToEdit as WebPartDemo).DefaultTitle;       }    } }

 

下面就是在我们的实际的运用中,运用到他,代码测试过,可以直接运用。

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;
using System.Collections.Generic;
namespace WebPartDemo {    [Guid("f7145e12-c25e-419f-90bd-ffe928ba084d")]    public class WebPartDemo : System.Web.UI.WebControls.WebParts.WebPart    {       public WebPartDemo()       {          this.ExportMode = WebPartExportMode.All;       }
      
private string _defaultTitle;
      [Personalizable(), WebBrowsable(),       WebDisplayName(
"默认标题"), WebDescription("列表项的默认标题"),       SPWebCategoryName("新建设置")]       public string DefaultTitle       {          get { return _defaultTitle; }          set { _defaultTitle = value; }       }
      
private bool _customBool;       [Personalizable(), WebBrowsable()]       public bool CustomBool       {          get { return _customBool; }          set { _customBool = value; }       }
      
private TextBox input;       private Button btn;       //编辑类主要靠这里的。。相信大家看看就明白啦       public override EditorPartCollection CreateEditorParts()       {          List<EditorPart> list = new List<EditorPart>();(范性)          MyEditor me = new MyEditor();          me.ID = this.ID + "_me";          list.Add(me);          return new EditorPartCollection(list);       }
      
protected override void CreateChildControls()       {          input = new TextBox();          Controls.Add(input);          btn = new Button();          btn.Text = "Add!";          btn.Click += new EventHandler(btn_Click);          Controls.Add(btn);       }       protected override void OnPreRender(EventArgs e)       {          input.Text = this.DefaultTitle;       }       void btn_Click(object sender, EventArgs e)       {          if (Page.IsValid)          {             this.DefaultTitle = input.Text;             this.SetPersonalizationDirty();          }       } } }

希望对MOSS开发的哥们有帮助,其实开发就是要多练习列子。。大家一起加油吧!

相信大家对自定义工具栏很有兴趣吧,在家里研究拉一下,把自己的代码给贴出来,给大家喜欢研究MOSS的哥们研究,研究 , 其实就是继承一个编辑类就OK拉,这个自定义工具栏,在实际的MOSS开发中,很有帮助的,很多地方需要他

转载于:https://www.cnblogs.com/masahiro/archive/2011/05/06/10128289.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值