Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message in multiple languages

Good day everyone,

I have a doubt on my currently development, the thing is i've created a project using ntier and data application block for my data access layer so, i have a package named Entities where i create all my classes and i was trying to use error messages mapped to a resource file the problem is when i write the following code it marks up with error:

(Entity-Base-Clients)

public partial class Clients {

public Int32 Id {get;set;}
[Display(Name="Name", 
ResourceType=typeof(Resources.Language))] 
[Required(AllowEmptyStrings=false, 
ErrorMessageResourceName="Id", 
ErrorMessageResourceType=typeof(Resources.Language))] 
public string Name {get;set;}
}

In the following code it marks up error in "Resources" (which is the folder where i put my resource files) and "Language" is the resource file.

But when i do the exactly the same thing on the "Model" folder didn't marks up any error

(Model-Clients)

public Int32 Id {get;set;}
[Display(Name="Name", 
ResourceType=typeof(Resources.Language))] 
[Required(AllowEmptyStrings=false, 
ErrorMessageResourceName="Id", 
ErrorMessageResourceType=typeof(Resources.Language))] 
public string Name {get;set;}
}

Do i have doing something wrong? am i missing a reference or configuration of the RF?

Thanks in advance

like image 485
Alex Avatar asked Nov 12 '22 21:11

Alex


1 Answers

[Display(Name = "Name"), Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName ="nameHasToBeGiven")]
        public string name { get; set; }

this one is way easier

like image 139
alkanschtein Avatar answered Nov 15 '22 12:11

alkanschtein