I have a Contact/Index page split into two columns (for each column one PartialView). On the left I show the list of all my contacts and on the right the details of the selected/clicked contact from the said list.
...and the preview works great -> after a user clicks a record from the list I just call a '@Url.Action' for an action in my controller that returns a partial view with the details.
<div class="row">
<div class="col-md-8 col-sm-12">
<div id="sectionList">
@{await Html.RenderPartialAsync("_PartialList", Model.Contacts);}
</div>
</div>
<div class="col-md-4 col-sm-12">
<div id="sectionPreview" style="display: block">
@{await Html.RenderPartialAsync("_PartialPreview", Model.Contact);}
</div>
<div id="sectionEdit" style="display: none">
@{await Html.RenderPartialAsync("_PartialEdit", Model.Contact);}
</div>
</div>
</div>
But I'm having a problem with 'edit'. On the details form I have a button for EDIT and when a users clicks it I want to HIDE the PartialView for preview (id="sectionPreview") and SHOW the one for edit (id="sectionEdit").
I already tried playing around with saving different styles (disply: block or none) to ViewBag and applying that to each section, but it doesn't feel like the right approach, because all the PartialViews (even with display set to none) still get rendered.
What is the best way/practice to make this work?