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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:09:45+00:00 2026-06-16T04:09:45+00:00

Scenario :- I am developing MVC 4 application, the website will run in several

  • 0

Scenario :-
I am developing MVC 4 application, the website will run in several languages and will be hosted on Azure.
For localizing we are relying on the database rather than resource bundle approach.

Problem :-
I want to customize error messages at runtime, I want to localize the messages through the database.

I have tried to change attribute values through reflection but it had not worked.

Code :-

     //Model
      public class Home
      {
          [Required(ErrorMessage = "Hard coded error msg")]
           public string LogoutLabel { get; set; }
      } 

     //On controller
      public ActionResult Index()
    {
        Home homeData = new Home();
        foreach (PropertyInfo prop in homeData.GetType().GetProperties())
        {
            foreach (Attribute attribute in prop.GetCustomAttributes(false))
            {

               RequiredAttribute rerd = attribute as RequiredAttribute;

                if (rerd != null)
                {
                    rerd.ErrorMessage = "dynamic message";
                }
            }


        }

        return View(homeData);
    }  

On client side when validation takes place it shows me old message “Hard Coded error msg”.
Please suggest how this can be customised if we donot want to use Resource bundle approach

  • 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-16T04:09:47+00:00Added an answer on June 16, 2026 at 4:09 am

    You would better create and register your own DataAnnotationsModelMetadataProvider where you can just override the error messages. For more detail please see the answers to the similar question here MVC Validation Error Messages not hardcoded in Attributes

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

Sidebar

Related Questions

We are developing an Client-Server-Scenario where the client application will be installed on hundred
Scenario: Every page on the website will have a menu bar at the top
Hey, can anybody confirm the following scenario will work: I am developing a 3-tier
Hi every body i am developing a MVC application, and i want to use
I am developing a java application. I have scenario to take screen shot of
I’m developing for several months an application and every now and then I think
Scenario: Developing on hosted server, htaccess = Basic Auth, allow_url_fopen = on Problem: When
Scenario I am developing an application that intensively use randomly generated values. I have
I am developing a winforms application and I have a scenario where I want
I'm developing an application with Google App Engine and stumbled across the following scenario,

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.