Randy Minder
Randy Minder

Reputation: 48522

Cannot get model variable to display on page

In my MVC 5 app, I have a page with some HTML at the top of the page that looks as follows:

@model Entities.SightingSearch

<div class="page-header">
    <h3 class="text-center">Sightings</h3>
    <h4 class="text-center">@Html.Label(Model.CurrentTaxonomy,"Taxonomy: ")</h4>
</div>

The SightingSearch entity has a property name 'CurrentTaxonomy' and it does contain a value when the page is rendered. However, I cannot get the value to display on the page. All I get is the label text of "Taxonomy: ". I'm guessing I'm overlooking something very basic here.

Upvotes: 0

Views: 73

Answers (1)

wbennett
wbennett

Reputation: 2563

Change it to Taxonomy: @Html.DisplayFor(model => model.CurrentTaxonomy)

Upvotes: 1

Related Questions