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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:15:22+00:00 2026-05-14T00:15:22+00:00

I have a localized application, and I am wondering if it is possible to

  • 0

I have a localized application, and I am wondering if it is possible to have the DisplayName for a certain model property set from a Resource.

I’d like to do something like this:

public class MyModel {
  [Required]
  [DisplayName(Resources.Resources.labelForName)]
  public string name{ get; set; }
}

But I can’t to it, as the compiler says: “An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type” 🙁

Are there any workarounds? I am outputting labels manually, but I need these for the validator output!

  • 1 1 Answer
  • 3 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-14T00:15:23+00:00Added an answer on May 14, 2026 at 12:15 am

    How about writing a custom attribute:

    public class LocalizedDisplayNameAttribute: DisplayNameAttribute
    {
        public LocalizedDisplayNameAttribute(string resourceId) 
            : base(GetMessageFromResource(resourceId))
        { }
    
        private static string GetMessageFromResource(string resourceId)
        {
            // TODO: Return the string from the resource file
        }
    }
    

    which could be used like this:

    public class MyModel 
    {
        [Required]
        [LocalizedDisplayName("labelForName")]
        public string Name { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a resource dictionary of localized strings. I want to set a property
Is it possible to customize a django application to have accept localized date format
I have a monolingual GWT application (English) and I would like to use localized
I have an .NET application with satellite assemblies containing resource to be localized, but
If you have an application localized in pt-br and pt-pt , what language you
I have a localized iOS application in which I wish to include some localized
I have trouble understanding the following thing: in my localized application I have an
I have an application that is supposed to be localized (two languages, english being
I have already released an iOS application that is localized in english and greek
I have an PHP application that I want localized. Currently, the way I'm doing

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.