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

  • Home
  • SEARCH
  • 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 6643951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:06:38+00:00 2026-05-26T00:06:38+00:00

When I put [Required] attribute on my ViewModel’s property MVC3 automatically generate error messages

  • 0

When I put [Required] attribute on my ViewModel’s property MVC3 automatically generate error messages like:
The Price field is required.

My site’s single language is Russian, so I want to have localized error messages. I can localize field’s name with [Display(Name = "blablabla")], but how can I localize the field is required part?

Update:
I know, that I can change an error message for concrete field by specifying it [Required(ErrorMessage = "blablabla")], is there a way I can change it in one place for all [Required] attributes, so I could use just [Required] without additional parameters, and it took the localized error message from some ressource/config/etc?

  • 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-26T00:06:39+00:00Added an answer on May 26, 2026 at 12:06 am

    I’ve created an alternative solution where you don’t have to use the attributes for the localization. I’ve created custom model/validation meta data providers.

    All you need to do is to download my code and do the following in your global.asax:

    var stringProvider = new ResourceStringProvider(Resources.LocalizedStrings.ResourceManager);
    ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(stringProvider);
    ModelValidatorProviders.Providers.Clear();
    ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider(stringProvider));
    

    (the ResourceStringProvider is my default implementation but it’s easy to create an alternative that reads from XML files or a database)

    You can read about it here:
    http://blog.gauffin.org/2011/09/easy-model-and-validation-localization-in-asp-net-mvc3/

    I’m going to release a nuget package as soon as I’m finished with my view localization and my alternative HTML helpers.

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

Sidebar

Related Questions

How can I just put the value of DisplayName attribute of model's property instead
I would like to put a constant date time in an attribute parameter, how
I know it sounds weird but I am required to put a wrapping try
let's say I have 2 classes like this: public class Foo { [Required] public
When defining a PUT method on a resource is it required/standard/customary to include the
is it possible to use System.ComponentModel.DataAnnotations and it's belong attribute(such as Required , Range
I am using the Authorize attribute like this: [Authorize (Roles=Admin, User)] Public ActionResult Index(int
I am using MVC3 and added model validation with required attributes. Then I have
Where should I put require_once statements, and why? Always on the beginning of a
Put differently: Is there a good reason to choose a loosely-typed collection over a

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.