首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharePoint 2010 Wiki页面库-限制在Wiki页面中插入Web部件

SharePoint 2010 Wiki页面库-限制在Wiki页面中插入Web部件
EN

Stack Overflow用户
提问于 2013-09-30 18:46:23
回答 1查看 430关注 0票数 0

我们有一个特定的业务需求,我们需要允许用户在Wiki库中创建Wiki页面,但限制用户将web部件添加到Wiki页面中。如果我们为用户提供对Wiki库的访问权限,则用户可以通过单击Insert并添加现有的web部件来添加web部件。

是否有人知道用户可以通过编辑页面来贡献网页的内容,而不向页面添加web部件呢?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-03 17:40:14

如果可以添加自定义代码,则可以为wiki的列表项ItemUpdating事件创建事件接收功能,以检查是否存在web部件并取消保存和显示消息。

如果只希望对单个实例进行操作,那么下面的示例代码将修改下面的示例代码,以检查要控制的wiki库实例。

代码语言:javascript
复制
public override void ItemUpdating(SPItemEventProperties properties)
        {               
            base.ItemUpdating(properties);                      
            SPListItem item = properties.ListItem; //get the list item being updated
            string pageUrl = item.Url; //get the item url for the web part manager
            SPLimitedWebPartManager lwpm = properties.Web.GetLimitedWebPartManager(pageUrl, PersonalizationScope.Shared); //get the web part manager
            if (lwpm.WebParts.Count > 0) //test for the presence of any web parts
            {
                properties.Cancel = true; //cancel the save
                properties.ErrorMessage = "WebParts are not allowed on this wiki page."; //display message to the user
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19101519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档