Question

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?

Was it helpful?

Solution

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

OTHER TIPS

I agree with James, I don't think it can be done easily. You can grant it the ability to change or not to change. Once a user places it on a page, they'll know quickly where to put it, to me it seems to be more work than is needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top