@if + lambda in an editor template
-
31-10-2019 - |
Question
I have something for which I can't find the right syntax:
/Views/Shared/EditorTemplates/Component.cshtml
@model Website.Models.Component
<div class="editor-field">
@if (x => x.Name == "")
{
@Html.EditorFor(x => x.Name)
<button class="create">New</button>
}
else
{
@Html.DisplayFor(x => x.Name)
<button class="delete" value="@Model.Id">X</button>
}
</div>
I hope the intention is clear... how do I get there (it's hard to google for this sort of thing)?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow