0

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.

1
  • @Html.Label() displays the property name (or the value of the DisplayNameAttribute), not the property value. You need @Html.Display() Commented Jul 18, 2014 at 13:55

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Works perfectly. Funny thing is that I'm sure I tried this. I guess not. Thank you.
You are welcome. I have experienced similar behavior when making live edits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.