Open Closed

How to I Localize Text in Data Annotation of View Models or DTO? #1437


User avatar
0
yuemy@sph.com.sg created

How to I Localize Text in Data Annotation of View Models or DTO?

example below

[Required]
[StringLength(256)]
[Placeholder("Enter Category Code")]
[Display(Name = "Code")]
[PageRemote(
    ErrorMessage = "Code already exists",
    HttpMethod = "get",
    PageHandler = "ValidateCode"
)]
public string CategoryCode { get; set; }

How to localize the Placehoder text, the PageRemote validation error message and the required error message?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Fullstack Developer

    Hi, you just need add localize text to the localized resource file.

    public class TestDto
    {
        [Required(ErrorMessage = "Code already exists")]
        public string Name { get; set; }
    
        [Required]
        public string Title { get; set; }
    }
    

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 09, 2026, 11:56
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.