2010-08-03 3 views
5

는 다음 코드를 MSDN에서 잡고되었다 : 오류 메시지 : (리소스 파일에서 예) http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspxStringLengthAttribute 및 지역화 된 텍스트

[MetadataType(typeof(ProductMetadata))] 
public partial class Product 
{ 

} 

public class ProductMetadata 
{ 

    [ScaffoldColumn(true)] 
    [StringLength(4, ErrorMessage = "The ThumbnailPhotoFileName value cannot exceed 4 characters. ")] 
    public object ThumbnailPhotoFileName; 

} 

가 어떻게 텍스트를 지역화 적용 할 수 있는가?

답변

7

리소스 파일을 참조하려면 ValidationAttribute.ErrorMessageResourceType 속성을 사용하고 해당 리소스 파일 내의 문자열 이름을 참조하려면 ValidationAttribute.ErrorMessageResourceName 속성을 사용하십시오. 예를 들면 : 당신이 더 많은 예제가 필요한 경우

[StringLength(4, ErrorMessageResourceType = typeof(YourResourceFileHere), ErrorMessageResourceName = "NameOfStringInResourceFile")] 

는 또한 this blog post을 확인할 수 있습니다.

관련 문제