In Razor view, how to check model property is null?

Total Post:26

Points:182
.NET  Mvc 
 761  View(s)
Ratings:
Rate this:

In Razor view, how to check model property is null?

       @if
(Model.ImageName != null)
            {
            }
            else
            {
            }

 I am writing this code but it is not working.  Please help me.

  1. Post:45

    Points:323
    Re: In Razor view, how to check model property is null?

    Try this 


    <div id="divLoading">
           @if (Model != null && !String.IsNullOrEmpty(Model.Record))
    {
        <label for="record">add record</label>
    }
    else
    {
        <label for="remove">remove</label>
    }
     
        </div>

     hope it helps you

      Modified On Apr-11-2018 11:06:30 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!