Question: In ASP.Net MVC5, how do I show a text box for a number in my ViewModel but have it show a blank when that value is 0?
Answer:
Let’s assume you have a ViewModel on the page that has an integer value that represents a month. If the ViewModel is empty and that value is 0 (a month hasn’t been set yet)
@Html.TextBoxFor(x => x.Month, “{0:#.#}”)