1

I created this model class:

 public class test5
{
    [Required] //when title field empty send from client this is show this messae" The title field is required."
    public string title { get; set; }
    public int content { get; set; }
}

I want edit Required filed error message to custom message and when I use that validation like [Required] anywhere display that error message. how I can do this?

1 Answer 1

1

Use keywoard ErrorMessage in dataanotation

public class test5
{
[Required(ErrorMessage = "CUSTOM ERROR MESSAGE")]
    public string title { get; set; }
    public int content { get; set; }
}
Sign up to request clarification or add additional context in comments.

4 Comments

I know this way, but I want change Required default message in where required defined?
Have a look at this project here codeproject.com/Tips/780992/…
I want change default error message that micro-soft defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.