1

正しい構文が見つからないものがあります。

/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>

意図が明確であることを願っています...どうすればそこにたどり着きますか(この種のことをグーグルで検索するのは難しいです)?

4

1 に答える 1

2

x => x.whateverラムダ式です。デリゲートを作成します。

条件内では、おそらく次のプロパティifを使用して、通常の式が必要です。Model

@if (String.IsNullOrWhitespace(Model.Name)) {
于 2011-05-10T01:12:03.787 に答える