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 8590257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:15:16+00:00 2026-06-11T23:15:16+00:00

I am working with a ASP.NET MVC4 application. I have created a view model

  • 0

I am working with a ASP.NET MVC4 application. I have created a view model which contains menu items and I can switch languages in page by Resources file.

#region Properties
[Display(Name = "MenuText", ResourceType = typeof(App.App_Resources.Menu))]
public string menuText { get; set; }

public List<MenuItem> menuItems { get; set; }
#endregion

However, I want to get this resource string in my .cshtml file, then I try as following

@model App.Models.MenuViewModel
@Html.LabelFor(model => model.menuText)            <- Success
@Html.DisplayForModel("menuText")                  <- Success
@Model.menuText                                    <- Fail

I inserted a break point and found out that Model contains a property which name is menuText but value is null. And I checked that Html also contains a property Model and its menuText also is null.
However, menuItems has items since I assign objects in constructor.

  1. Why the menuText cannot be initialized and assigned value to it?
  2. Why I can succeed to show the resource string with first two but Model.menuText is null and fail to show anything? What is different between the models in @Html.XXX and @Model?
  • 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-11T23:15:17+00:00Added an answer on June 11, 2026 at 11:15 pm

    @Model.menuText retrieves the raw string value stored within the menuText property. Attributes are ignored.

    Using LabelFor causes the Display attribute of the property to be examined. The localised string is stored in the attribute, not the property.

    Note that I think the Model object/class should not be used to store information for display (that’s what ViewData is for), but rather only for round-trip data that is sent from the client to the server.

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

Sidebar

Related Questions

I am working on asp.net MVC 3 application. I have created a Razor view
I am working on asp.net application and I have generated entity model (edmx) from
I'm working on an asp .net mvc 4 application. I have created a database
I am working on an asp.net MVC4 application. In my layout page, I have
I am working on asp.net 3.5 application. I have a datagrid. I want to
i am working in asp.net mvc 3 web application which uses razor code. and
I am working on asp.net application. I have a function like this: Public Function
I am working in Asp.net MVC and have a peculiar requirement for which I
My use-case: I already have a working ASP.NET application I would like to implement
I have a web application which was using Asp.net MVC2 . I Upgraded it

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.