Limit blocks in ContentArea


Hi guys,

What would be the best way limit the number of blocks allowed to be placed inside a ContentArea? Would this need to be a custom control or is there a way to limit this in the admin system?

I'm quite new to EPiServer, so if someone has some example code, that would be fabulous :-)


Oct 25, 2013 12:59

You could add a validator. See an example for ContentAreas in this thread:

This example validates the type of Content but you could easily change it to number of Blocks

Oct 25, 2013 13:15

Thanks Alf. That seems like it could work!

How would I keep track of how many blocks there are in the ContentArea, using that example as a starter?

Oct 25, 2013 15:02

You can look at the ContentArea.Contents for each Content/Block/Page added.

Use Linq methods such as .Count() to find out the amount.

If you want to re-use this validation on several Page Types, you can create a separate validator.


See more at

The value should be parsed to ContentArea instead of PageReference as is used in the example.

Oct 25, 2013 15:08

Thanks Alf, I'll check it out :-)

Oct 25, 2013 16:23

Is this still the best solution as of EPiServer 8?

May 11, 2015 18:48
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.