惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
J
Java Code Geeks
博客园_首页
Scott Helme
Scott Helme
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
V
Visual Studio Blog
Cloudbric
Cloudbric
Jina AI
Jina AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
W
WeLiveSecurity
K
Kaspersky official blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
量子位
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 三生石上(FineUI控件)
Recent Commits to openclaw:main
Recent Commits to openclaw:main

博客园 - 陈典洪

ASP.NET生成Excel文件的历程总结 C# Excel操作类 SharePoint 2010 安装部署 用VSTA动态改变infopath数据源查询参数与反回查询结果 将excel2003转换为excel2007格式 在sql server 中如何移动tempdb到新的位置 禁用MOSS2007“我的网站”功能 使用Exchange 2007搭建多域名邮件系统 Exchange 2007 配置 如何简化Exchange 2007 OWA URL访问 [转载]利用MOSS文档库自制一个山寨版mp3在线播放器 - 陈典洪 - 博客园 MOSS中自定义WebService与客户端应用 将项目从vs2008转到Vs2005的办法 如何控制列表视图栏位的宽度? WSS(MOSS)如何修改Rich文本编辑器的宽度 WSS 3.0 and MOSS 2007 SDK 更新到了1.5版本啦 moss 自定义文档库文档图标 - 陈典洪 - 博客园 moss 列表类型和对应类型编号 MOSS LIST的一些属性说明
用VS2010为SharePoint 2010 添加Ribbon自定义按钮
陈典洪 · 2010-07-26 · via 博客园 - 陈典洪

第一步:创建Feature1、用VS2010 新建一个sharepoint 2010 的Empty Sharepoint Project 项目,名称为CustomRibbon。

2、在Features 目录上,添加一个Feature,名称为CustomRibbonButton。

3、定义Feature文件。打开CustomRibbonButton.template.xml文件,进行编辑并保存,代码如下:

 <?xml version="1.0" encoding="utf-8" ?>
 
<Feature Id="A8DA4BE9-8F82-4E94-9723-D51E8B5D683E"
  Title
="CustomRibbonButton"
  Description
="CustomRibbonButton"
  Version
="1.0.0.0"
  Scope
="Web"
  xmlns
="http://schemas.microsoft.com/sharepoint/">
  
<ElementManifests>
    
<ElementManifest Location="CustomRibbonElement\Elements.xml" />
  
</ElementManifests>
 
</Feature>

第二步:创建支持文件

1、在CustomRibbon项目上,添加新项,选择Empty Elements类项,名称为CustomRibbonElement。

2、定义支持文件。打开Elements.xml文件,进行编辑,代码如下:

代码

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 
 
<CustomAction
   
    
Id="CustomRibbonButton"
    RegistrationId
="101"
    RegistrationType
="List"
    Location
="CommandUI.Ribbon"
    Sequence
="5"
    Title
="Move Documents">
    
<CommandUIExtension>
      
<CommandUIDefinitions>
        
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
          
<Button
              
Id="Ribbon.Documents.New.TestButton"
              Alt
="Move Documents"
              Sequence
="5"
              Command
="Test_Button"
              Image32by32
="/_layouts/images/CustomRibbon/network32.GIF"
              Image16by16
="/_layouts/images/CustomRibbon/network16.GIF"              
              LabelText
="Move Documents"
              TemplateAlias
="o1" />
        
</CommandUIDefinition>
      
</CommandUIDefinitions>
      
<CommandUIHandlers>
        
<CommandUIHandler
          
Command="Test_Button"
          CommandAction
="javascript:alert('Welcome To SharePoint 2010 !');" />
      
</CommandUIHandlers>
 
    
</CommandUIExtension>
  
</CustomAction>
 
</Elements>

备注说明:
  "CustomAction“部分:
  “Sequence” 属性,这个属性指定了我们要添加的按钮所在组中的位置。
   “Location” 属性,这里指定了这个按钮应该被添加到哪个Tab下的哪个组中,其格式为:Ribbon.[Tab].[Group].Controls._children

  "Command” 属性,这个属性将“CommandUIDefinition” 与“CommandUIHandler” 关联起来。
  “TemplateAlias” 属性,定义了这个按钮在页面中是32X32还是16X16,“o1”是32,“o2”是16。

  “CommandUIHandler” 部分:

  “Command” 属性与第19行的“Command” 相对应,以将Button与其操作关联起来。
  “CommandAction” 标记,在这个标记中我们将定义按钮被按下时将要执行的Javascript脚本。SharePoint 2010为我    们提供了丰富的Javascript API,通过这些API我们可以做更多的事情。

第三步:部署

1、选择CustomRibbon项目,查看属性,在SiteUrl属性上,填写部署的站点,如:http://moss

2、选择CustomRibbon项目,右键“部署”将进行自动部署

第四步:查看效果

1、打开一个文档库,选择一个条目,在文件这个标签上,就可以看到刚刚部署的这个ribbon 按钮了。

注:用VS2010进行sharepoint 2010的开发还是挺方便的,能够很好的跟sharepoint集成,方便开发,部署与调试。