I am facing this issue that I want to remove empty div if there is an active visitor group on the block.
This is a content area which will only contain one block and that block is supposed to have visitor group (e.g. persons age < 35 )
When the person is over 35 the block is hidder but there is still an empty div. How can I remove that ?
<div class="col-xs-12 col-md-6 col-lg-3">
@Html.PropertyFor(x => x.CurrentPage.ContentArea)
You can check the content area items and see if any items are returned.
It is preferable to use the filtereditems property as this will apply personalization, etc.
More info can be found here https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/common-web-page-component-tutorials/getting-items-within-an-episerver-content-area-in-code-items-and-filtereditems-explained/
Alternatively you could get the current users visitor groups and check if they are in the specific group. This method is more limited however.