DotVVM Tip 01: Visible binding

Published: 10/17/2022 12:59:00 PM

DotVVM Tips is a series of short articles showing interesting features of DotVVM. To learn more, visit our Docs site.

DotVVM syntax is different from Razor. Instead of the @if statement, use the Visible property on any HTML element and bind it to a boolean expression.

// Razor
@if (orders.Count == 0)
    <div class="order-list">
        <h2>No orders placed</h2>

// DotVVM
<div class="order-list" 
     Visible="{value: Orders.Count == 0}">
    <h2>No orders placed</h2>

There is also IncludeInPage with a similar meaning. The Visible property just hides the element using CSS display property while IncludeInPage removes it from the DOM.

Tomáš Herceg

I am the CEO of RIGANTI, a small software development company located in Prague, Czech Republic.

I am Microsoft Most Valuable Professional and the founder of DotVVM project.