lundi 23 mai 2016

How can set condtion on img tag in asp.net mvc

I have problem with if condtion and img tag in razor syntax. I want img tag create when imgurl in database be not null. Please help me.

<div class="activity-desk">
        <div class="panel">
            <div class="panel-body">



                <div class="arrow-alt"></div>      

                <i class=" icon-time"></i>
                @{
                    PersianDateTime persianDate = new PersianDateTime(item.Date.Value);

                }
                <h4 style="font-family: 'yekan'; color: #377687;"> @persianDate.ToStringDateTime12P()  |@item.Date.Value.ToStringShamsiDate()   </h4>
                <p>@item.Text</p>

                @if (item.ImageUrl!=null)
                {
                    @Html.Raw("<img style=""border: 5px groove white;border-radius: 5px;text-align: center;margin-top: 50px;width: 500px;"" src=""@Url.Content(item.ImageUrl)"">")
                }

            </div>

        </div>
    </div>

Aucun commentaire:

Enregistrer un commentaire