简体   繁体   English

Sharepoint Web部件仅限于区域

[英]Sharepoint Web Part restrict to zone

Is there any way to restrict a web part to a certain zone? 有什么方法可以将Web部件限制在特定区域吗? 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? 我知道我可以通过使用AllowZoneChange标志来限制它,但是可以确保Web部件只能添加到某些区域吗? 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). 我有一些Web部件仅在宽列(区域)中可用,因此,我想确保没有人尝试将Web部件添加到窄列(区域)中。 Is there any way of accomplishing this? 有什么办法可以做到这一点?

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. 如果坚持使用与“宽”同名的快速添加组,则当有人尝试在该区域中添加Web部件时,默认情况下它将显示在列表顶部。

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. 但是,我认为实际上根本不可能做到这一点-我能想到的唯一方法就是(以某种方式,也许直接通过修改页面布局)将一些代码添加到事件处理程序中。用于SPWebPartManager.WebPartAdded来检查Web部件和区域,如果添加到错误的区域中,则将其删除。

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 http://msdn.microsoft.com/EN-US/library/ms157584

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM