Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:51:50+00:00 2026-06-17T09:51:50+00:00

I am trying to override the caption generated by the two MVC 3 Razor

  • 0

I am trying to override the caption generated by the two MVC 3 Razor extensions below. I would like to show “Is Enabled” instead of “IsEnabled”.

@Html.DisplayFor(modelItem => item.IsEnabled)

and

@Html.LabelFor(model => model.IsEnabled)

My property is decorated as follows:

[DisplayName("Is Enabled")]
public bool IsEnabled { get; set; }

The LabelFor method seems to respect the DisplayName attribute; it works just fine. However, the DisplayFor method does not pick up the DisplayName attribute.

Any ideas on how I can override the caption of a property for both Razor methods?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:51:52+00:00Added an answer on June 17, 2026 at 9:51 am

    You’re mixing title and content (or name of a property and its value)

    DisplayFor is for the content (value of the property of the instance), so shows true or false (or a checkbox checked or not) for a boolean.

    LabelFor is… a label (kind of title), so it will show the name of the property (IsEnabled if you don’t put a DisplayName attribute), and the value of the DisplayName attribute if it exists

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to manually override the value for caption and bClose for the
I'm trying to override onDraw in an EditText subclass, to show a custom subtitle.
I am trying to override DS to use '/' instead of '\' in my
Trying to override the id attribute of Html.TextBoxFor (MVC 3) so that it should
I'm trying to override a built in parseFloat function in JavaScript . How would
Trying to override a tostring in one of my classes. return string.Format(@ name =
im trying to override the add() but it will not compile public class AVLTree<E
I'm trying to override a JSP in Liferay 6.1, namely html/portlet/enterprise_admin/settings/authentication.jsp. I have created
I'm trying to override a method inside a jquery widget. The method can be
If I am trying to override a specific tag inside multiple classes, do I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.