我们有一个特定的业务需求,我们需要允许用户在Wiki库中创建Wiki页面,但限制用户将web部件添加到Wiki页面中。如果我们为用户提供对Wiki库的访问权限,则用户可以通过单击Insert并添加现有的web部件来添加web部件。
是否有人知道用户可以通过编辑页面来贡献网页的内容,而不向页面添加web部件呢?
谢谢
发布于 2013-10-03 17:40:14
如果可以添加自定义代码,则可以为wiki的列表项ItemUpdating事件创建事件接收功能,以检查是否存在web部件并取消保存和显示消息。
如果只希望对单个实例进行操作,那么下面的示例代码将修改下面的示例代码,以检查要控制的wiki库实例。
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
}
}https://stackoverflow.com/questions/19101519
复制相似问题