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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:20:34+00:00 2026-06-11T03:20:34+00:00

My ValidationAttributes don’t access my ErrorMessages value-pairs stored in a .resx Resource File generated

  • 0

My ValidationAttributes don’t access my ErrorMessages value-pairs stored in a .resx Resource File generated with VS2010 built in resource generator. (Add New Item – Resources File)

I simply added a folder named Resources, then added a new Resources File and called it ErrorResources, in the resources editor I added a value pair StringLengthError – Too Long**.

Then in my DataAnnotation.ValidationAttribute I wrote:

  [StringLength(5, MinimumLength = 3, 
                    ErrorMessageResourceType = typeof(ErrorResources),
                    ErrorMessageResourceName = "StringLengthError")]
  public string Details { get; set; }

I added a using statement to include the ErrorResources.

But when I run it, the ValidationAttribute StringLength is totally void.

If I use it without the ErrorResources, as in :

  [StringLength(5, MinimumLength = 3)]
  public string Details { get; set; }

The validation attribute comes back to life.

I tried accessing the ErrorResources value pairs in other part of the code, and it works. I just can’t get my ValidationAttributes to use the ErrorResources resource.

  • 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-11T03:20:35+00:00Added an answer on June 11, 2026 at 3:20 am

    Access modifier should be Public but that’s not enough.
    You will have to change properties of your resx file to look like this:

    Properties

    Pay attention to Build Action and Custom Tool

    In addition Resx used by data annotations should sit in App_GlobalResources rather than in Resources you’ve mentioned. Try these, see if that works alright.

    Hope this will help you.

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

Sidebar

Related Questions

Is there anyway to override the custom validation error messages from the ValidationAttributes? Basically
We have quite a few validation methods that need to access repositories / database
How do you get the validation metadata for the built in validation attributes? I'm
I am trying to adhere to best multi-layer design practices, and don't want my
When I post a 'Model' object (as generated by LinqToSQL) to a controller, I
Current validation method for use in MVC 3 seems to be ValidationAttributes. I have
I am trying to develop some general purpose custom ValidationAttributes. The fact that one
I want to utilize Validator.TryValidateValue() but don't understand the mechanics. Say, i have the
The question here is similar, but I don't have any domain object inheritance. My
Thanks for any thoughts. while I am working my way through some custom validationAttributes,

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.