I am very new to C# and ASP.NET MVC Razor. I want to show a field in my view if the field is not blank.
-
The syntax might not be perfect, but try this:
@{
var trClass = string.IsNullOrEmpty(Model.phone2) ? "hide" : "";
}
@Html.LabelFor(model => model.phone2)
@Html.EditorFor(model => model.phone2)
@Html.ValidationMessageFor(model => model.phone2)
- 热议问题