lundi 24 avril 2017

Are compound statements required with if conditions in ASP.NET MVC?

I have a statement in MVC which I think looks better without the compound braces, but I cannot get it to work. The statement, when it works, is this:

<td>
    @if (SessionState.HasInvitations)
    {
        <a href='@ApplicationState.FormatInviteURL(item)'>@item.InviteNumber</a>
    }
    else
    {
        @item.InviteNumber
    }
</td>

I would like to remove the braces, but the following does not work...

<td>
    @if (SessionState.HasInvitations)
        <a href='@ApplicationState.FormatInviteURL(item)'>@item.InviteNumber</a>
    else
        @item.InviteNumber
</td>

Is there a way to do this which I'm simply missing or am I doomed?

Aucun commentaire:

Enregistrer un commentaire