Sharepoint Web 部件限制为区域
有什么方法可以将 Web 部件限制在某个区域吗?我知道我可以通过使用AllowZoneChange 标志来限制它,但是是否可以确保Web 部件只能添加到某些区域?我有一些仅在宽列(区域)中可行的 Web 部件,因此我想确保没有人尝试将 Web 部件添加到窄列(区域)中。有什么方法可以实现这一点吗?
Is there any way to restrict a web part to a certain zone? I know I can restrict it by using the AllowZoneChange flag, but is it possible to make sure the web part can only be added to certain zones? I have some web parts which are only viable in a wide column (zones), so I want to make sure that no one tries to add the web parts to narrow columns (zones). Is there any way of accomplishing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您坚持使用与“宽”组同名的快速添加组,则当有人尝试在该区域中添加 Web 部件时,默认情况下该组会显示在列表顶部。
但是,当有人尝试添加到另一个区域时,它会正常显示在列表中。
但是,我认为实际上根本不可能做到这一点 - 我能想到的唯一方法是(不知何故,也许通过直接修改页面布局)将一些代码添加到 SPWebPartManager.WebPartAdded 的事件处理程序中,以检查 Web 部件和区域,并在将其添加到错误区域时将其删除。
然而,我从未尝试过这样做,也不知道它是否有效 - 不过请随意尝试一下。如果您确实让它发挥作用,请在博客中介绍它!
查看此内容以获取有关活动本身的信息。
http://msdn.microsoft.com/EN-US/library/ms157584
If you stick in a Quick Add Group with the same name as your "wide" one, it'll show up at the top of the list by default when someone tries to add a web part in that zone.
However, it will show up as normal further odwn the list when someone tries to add to another zone.
However, I don't think it's actually possible to do this at all - the only method I can think of, off the top of my head is to (somehow, maybe through modifyin the page layout directly) add some code to an event handler for SPWebPartManager.WebPartAdded to check the webpart and the zone, and to remove it if it was added in the wrong zone.
However, I've never tried to do this, nor know if it would work - feel free to give it a try though. Blog about it if you do get it to work!
Have a look at this for info on the event itself.
http://msdn.microsoft.com/EN-US/library/ms157584