Table within the View

Asked

Viewed 72 times

0

I’m placing a table inside the Edit view.

View de Edit (Contract)

@if (Model.ContratoParcela.Any())
{
    <table class="table parcela-lista">
        @foreach (var parcela in Model.ContratoParcela)
        {
            <tr>
                <th>
                    <a href="#" data-contratoid="@parcela.id_Contrato" data-toggle="modal" data-target="#ModalParcelaEdit">@parcela.valor</a>
                </th>
            </tr>
        }
    </table>
}

But @if is in red, underlined.

I want to take the information from the Contratoparcela table and display in the Edit view that comes from the Contract table.

I make that mistake:

Unexpected "if" keyword after "@" Character. Once Inside code, you do not need to prefix constructs like "if" with "@".

  • Take @ out of the front of the if.

  • Was that right? Just take the @, Marcos?

1 answer

1

Apparently you are already inside a covered block by @. You can: Being in a situation like this:

@{
  if(true) { }
}

Or so:

@if(true) {
  if (true) { }
}

in both cases you already have a @ around if, so you don’t need to put another.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.