ToShortDateString is displaying empty string

asp.net-mvc, c#, entity-framework, razor

Solution

You don't see anything because you are not rendering anything.

Inside an `if` block you are in "code mode" in Razor so nothing gets written to the response unless you prefix with `@`.

So you just need to write:

@if (Model.bookings.tentative_date.HasValue)
{
    @Model.bookings.tentative_date.Value.ToShortDateString()
}

Problem

tentative_date has a valid date, but when I try to convert to `shortdate`, an empty string is displayed. ``` @if (Model.bookings.tentative_date.HasValue) { Model.bookings.tentative_date.Value.ToShortDateString(); } ``` Any ideas on what I'm doing wrong?

Original source