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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:14:00+00:00 2026-05-31T08:14:00+00:00

I am just extending my this question a bit. I have my App_LocalResources in

  • 0

I am just extending my this question a bit.

I have my App_LocalResources in my MVC web application (I don’t have it in separate dll).

I have a my Model in different assembly. In the Model I have 2 classes Country and City:

public class Country: MyContainer
{
    public City city {get;set;}
} 

public class City
{
    public CityName {get;set;}
}

public class MyContainer
{
    public Cid {get;set;}
}

So in my action method I create and pass an object of country as my viewmodel.

And in the view I use this:

@Html.LabelFor(mdl=>mdl.City.CityName)
@Html.LabelFor(mdl=>mdl.Cid)

So this works well and label with text are rendered in English.

But how do I modify this so that it reads the text from my Resource files in my web application?

  • 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-05-31T08:14:01+00:00Added an answer on May 31, 2026 at 8:14 am

    You could write a custom display attribute:

    public class LocalizedDisplayNameAttribute : DisplayNameAttribute
    {
        public LocalizedDisplayNameAttribute(string key): base(FormatMessage(key))
        {
        }
    
        private static string FormatMessage(string key)
        {
            // TODO: fetch the corresponding string from your resource file
            throw new NotImplementedException();
        }
    }
    

    and then:

    public class City
    {
        [LocalizedDisplayName("cityname")]
        public string CityName { get; set; }
    }
    

    You may also checkout the following localization guide. It provides a full implementation of a sample attribute.

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

Sidebar

Related Questions

Sorry just clearing my questions. Extending this question Optimizing sqlite query I have a
This question is language independent. I have an application that handles requests in a
Just a general question regarding the difference between extending a class and implementing it.
Just a knowledge question which I would like to ask: For example, I have
Extending from this questions about locales And described in this question : What I
I'm relatively(read: stupid newbie) familiar with disassembly but this bit stumped me: I have
I have a question about extending a class in PHP. The examples I see
This may be a question for a different forum, if so please let me
The gist of this question is about extending a class, minimizing jam-packing everything into
I have a question about extending a custom control which inherits from UserControl. public

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.