1

Why does @Html.DisplayFor() with a boolean value display either a disabled checkbox or disabled select (depending on nullable or not) insead of true/false/nothing?

With a string, for instance, I don't get a disabled textbox.. I get the value. Why the difference?

1
  • 2
    Because the library authors have determined that a disabled checkbox is the "right" way to display a boolean in a web page. I for one do not agree, then again they're the ones writing the library, so... Commented Mar 10, 2014 at 16:07

1 Answer 1

1

Most probably, because a checkbox doesn't need to be culture-dependent: you don't have to translate true/false/nothing in every possible language. So it's much more easy for the library authors to maintain...etc.

That being said, you can of course override this default behavior. See for example Using Razor, how do I make all "bool?" properties appear as Yes/No/Not Set on details pages?

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

Comments

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.