Let's say I have a partial view named 'Container' which contains two partial views called 'PartialA' and 'PartialB'. On the 'Conatiner' partial view I want some sort of configurational ability so that when we use the 'Container' partial view on the main view we can control the visibility of inner views, i.e. whether both PartialA and PartialB should be rendered or just render any of them or none of them at all. Basically I want main view to decide which inner views should be rendered.
What's the best way to achieve this?
Create a view model that you will pass to Container that will include 1 flags (or add to existing one):
public bool PartialAVisible;
public bool PartialBVisible;
Set the visibility flags as you wish the visibility to be in the Controller that will call your main view or inside the main view and pass it over to Container
In the Container perform the following logic
if (PartialAVisible)
@Html.Partial("PartialA", model)
if (PartialBVisible)
@Html.Partial("PartialB", model)
Hope this helps