mardi 16 juin 2015

check for value null on razor syntax

The following code is failing because propiedadesFormularioDetalle is null. I placed an IF before the block code but still not working, if I remove one of the bracked, then it wont compile

  @if (propiedadesFormularioDetalle != null) { }
                        <div class="panel panel-default">
                            <div class="panel-heading">Propiedades adicionales</div>
                            <div class="panel-body">
                                <dl class="dl-horizontal">
                                    @foreach (KeyValuePair<string, string> propiedad in propiedadesFormularioDetalle)
                                    {

                                        <dt>
                                            @Html.DisplayName(propiedad.Key)
                                        </dt>

                                        <dd>
                                            @Html.DisplayFor(prop => propiedad.Value)
                                        </dd>

                                    }
                                </dl>
                            </div>      
                        }                 
                    </div>

Aucun commentaire:

Enregistrer un commentaire