Marco Dinatsoli
Marco Dinatsoli

Reputation: 10590

mvc4 bool becomes a rectange instead of true and false

i have a model contains a bool value,

when i present that value in the view i got this image

enter image description here

how to make it just `True` or `False`

Upvotes: 0

Views: 80

Answers (2)

Tommy
Tommy

Reputation: 39817

It all depends on how you present the data (mark up) in your view.

@Html.EditorFor(m=>m.BoolValue) -> renders a checkbox so that the user can "edit" the data.

@Html.LabelFor(m=>m.BoolValue) -> renders the string "BoolValue" unless you have a data annotation ([DisplayName("Some New Name")]) naming it something different. This is to generate a label to associate with a checkbox.

@model.BoolValue -> Will render true or false, whatever the value of the BoolValue variable is.

Upvotes: 1

John H
John H

Reputation: 14640

Rather than using Html.EditorFor, you simply want to use @Model.IsFurnished.

Html.EditorFor will provide a checkbox for a bool because it is the most logical way to represent a value of true or false.

Upvotes: 1

Related Questions