dimanche 6 novembre 2016

Creating an IF - Else Statement in MVC Razor [duplicate]

This question already has an answer here:

I am getting an error Object reference not set to an instance of an object. in running my MVC Html Razor. I search on google on how to create an IF-Else in razor and found some good answer. But in my case I am getting an error.

My Code

<td  style="text-align: left" >
                    <div id="divEBSN">
                    @if (Model.RCEducationalBackground.School.SchooldName != null)
                       <span style="color: Red">@Html.DisplayFor(model => model.RCEducationalBackground.School.SchooldName)</span>    
                    else { 
                        <span style ="color:Red">@Html.DisplayFor(model => model.RCEducationalBackground.SchoolNameEducBG)</span>

Aucun commentaire:

Enregistrer un commentaire